Add remote commit check to container-build-and-release
Queries the Forgejo API to verify the target commit exists on the remote before dispatching a build, preventing wasted CI runs on unpushed commits. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
37b8a21524
commit
4dab6d11bb
2 changed files with 13 additions and 0 deletions
|
|
@ -89,6 +89,7 @@ def main(
|
|||
ref = git("rev-parse", ref)
|
||||
|
||||
short_sha = ref[:7]
|
||||
|
||||
image = f"blumeops/{container}"
|
||||
|
||||
# Show expected builds
|
||||
|
|
@ -120,6 +121,17 @@ def main(
|
|||
"Content-Type": "application/json",
|
||||
}
|
||||
|
||||
# Verify the commit has been pushed to the remote
|
||||
resp = httpx.get(
|
||||
f"{FORGE_API}/repos/{REPO}/git/commits/{ref}",
|
||||
headers=headers,
|
||||
timeout=15,
|
||||
)
|
||||
if resp.status_code != 200:
|
||||
typer.echo(f"Error: commit {short_sha} not found on remote")
|
||||
typer.echo("Push your changes before triggering a build: git push origin main")
|
||||
raise typer.Exit(1)
|
||||
|
||||
url = f"{FORGE_API}/repos/{REPO}/actions/workflows/{WORKFLOW}/dispatches"
|
||||
payload = {
|
||||
"ref": "main",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue