fix(ci): gate image publishing on test, lint, and security checks (#99)#128
Merged
Conversation
Publishing to GHCR previously ran on every push to `main` and every tag, without any dependency on the GoFortress test, lint, govulncheck, or gitleaks jobs. A failing test or vulnerable dependency could ship a release image. Restructure `build.yml`: - Trigger via `workflow_run` after the `GoFortress` workflow completes. - Add a `gofortress-gate` job that only succeeds when the upstream GoFortress run finished with `conclusion == 'success'`. - Chain `needs: [get_tag, gofortress-gate]` on `build-and-push`, so the GHCR push step cannot run unless lint, pre-commit, govulncheck, gitleaks, govet, and the test suite all passed. - Check out the exact `head_sha` GoFortress validated (instead of the current branch HEAD) to avoid publishing a different commit than was tested. - Keep `pull_request` and `workflow_dispatch` triggers for build-only verification; PRs already use `push: false`, and manual dispatch is operator-initiated. Closes #99 (F-041).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #99 (F-041).
build.ymlpreviously published a Docker image to GHCR on every push tomainand everyv*tag, with no dependency on the GoFortress test/lint/security jobs. A failing test, lint regression, vulnerable dependency (govulncheck), or leaked secret (gitleaks) could ship a release image.This PR makes image publishing a downstream step gated on a successful GoFortress run:
build.ymlnow triggers viaworkflow_runafterGoFortresscompletes (in addition topull_requestfor verification builds andworkflow_dispatch).gofortress-gatejob runs first; the job only proceeds whengithub.event.workflow_run.conclusion == 'success'.build-and-pushdeclaresneeds: [get_tag, gofortress-gate], so the GHCR push cannot run unless GoFortress's required gates all passed.head_shaGoFortress validated, so we never push a different commit than was tested.Gates required (all run inside GoFortress; verified by
workflow_runconclusion)code-quality(golangci-lint, yamllint, static analysis,go vet)pre-commitsecurity(govulncheck, nancy, gitleaks)test-magextest-suitesetup,warm-cacheGoFortress's own
status-checkjob already aggregates these and fails the workflow if any required gate fails, which is exactly whatworkflow_run.conclusion == 'success'reflects.Approach
A (recommended): keep gating in-repo and visible. The
needs:chain is now:with
gofortress-gateonly running when the upstreamGoFortressworkflow's conclusion issuccess.Notes / post-merge build behavior
mainwill no longer directly trigger an image publish. Instead, GoFortress runs on the push, and only on its successful completion doesbuild.yml(viaworkflow_run) build & publish. Time-to-publish increases by ~the GoFortress duration; this is intentional.v*): GoFortress's ownreleasejob already handles GoReleaser/tag releases. Image publishing now also flows throughworkflow_run; tag-named image tags viaworkflow_runare out of scope for this PR (workflow_run carries the head SHA, not the tag ref). If tag-named GHCR tags are needed, follow-up by reading the tag from the workflow_run payload or extending fortress-release to publish images.workflow_dispatch: gate still attaches, but operators can dispatch manually; treat as intentional.Test plan
build.ymlruns the build job (no push) and GoFortress runs in parallel as expected.main, confirm GoFortress runs first andbuild.ymlonly fires after GoFortress concludes successfully.build-and-pushfrom running (job is skipped viagofortress-gateif:).head_shaGoFortress validated.