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
1
docs/changelog.d/+container-release-push-check.misc.md
Normal file
1
docs/changelog.d/+container-release-push-check.misc.md
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
container-build-and-release now verifies the commit exists on the remote before dispatching a build.
|
||||||
|
|
@ -89,6 +89,7 @@ def main(
|
||||||
ref = git("rev-parse", ref)
|
ref = git("rev-parse", ref)
|
||||||
|
|
||||||
short_sha = ref[:7]
|
short_sha = ref[:7]
|
||||||
|
|
||||||
image = f"blumeops/{container}"
|
image = f"blumeops/{container}"
|
||||||
|
|
||||||
# Show expected builds
|
# Show expected builds
|
||||||
|
|
@ -120,6 +121,17 @@ def main(
|
||||||
"Content-Type": "application/json",
|
"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"
|
url = f"{FORGE_API}/repos/{REPO}/actions/workflows/{WORKFLOW}/dispatches"
|
||||||
payload = {
|
payload = {
|
||||||
"ref": "main",
|
"ref": "main",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue