From 4dab6d11bb8fc121abd2d467a6966122559faecd Mon Sep 17 00:00:00 2001 From: Erich Blume Date: Sat, 18 Apr 2026 08:03:21 -0700 Subject: [PATCH] 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) --- .../+container-release-push-check.misc.md | 1 + mise-tasks/container-build-and-release | 12 ++++++++++++ 2 files changed, 13 insertions(+) create mode 100644 docs/changelog.d/+container-release-push-check.misc.md diff --git a/docs/changelog.d/+container-release-push-check.misc.md b/docs/changelog.d/+container-release-push-check.misc.md new file mode 100644 index 0000000..ab9aedc --- /dev/null +++ b/docs/changelog.d/+container-release-push-check.misc.md @@ -0,0 +1 @@ +container-build-and-release now verifies the commit exists on the remote before dispatching a build. diff --git a/mise-tasks/container-build-and-release b/mise-tasks/container-build-and-release index 3549597..2e1be27 100755 --- a/mise-tasks/container-build-and-release +++ b/mise-tasks/container-build-and-release @@ -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",