Skip to content

Commit 71ee08d

Browse files
committed
gate merges on one check and isolate the release build
ci-ok aggregates every job of a CI run: it fails on any failure or cancellation and passes when everything triggered passed or was skipped. Branch protection requires only this one context, so conditional jobs never need enumerating in rulesets. The release job refuses to run outside this repository and builds without the Actions cache: cache entries are writable from any PR branch, so restoring one would let poisoned content reach the publishing build.
1 parent 1342b0c commit 71ee08d

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,18 @@ jobs:
6969
printf '%s\n' "$out"
7070
[[ "$code" -ne 0 ]] || { echo "image must exit non-zero without env" >&2; exit 1; }
7171
grep -q GERRIT_URL <<<"$out" || { echo "error must name the missing env var" >&2; exit 1; }
72+
73+
# ci-ok is the single branch-protection gate: it fails when any job of the
74+
# run failed or was cancelled, and passes when every triggered job passed
75+
# or was skipped — so conditional jobs never need enumerating in rulesets.
76+
ci-ok:
77+
if: always()
78+
needs: [lint, test, release-dry-run]
79+
runs-on: ubuntu-latest
80+
steps:
81+
- name: verify all jobs succeeded
82+
env:
83+
RESULTS: ${{ toJSON(needs.*.result) }}
84+
run: |
85+
echo "$RESULTS"
86+
[[ "$RESULTS" != *'"failure"'* && "$RESULTS" != *'"cancelled"'* ]]

.github/workflows/release.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ permissions:
1010

1111
jobs:
1212
release:
13+
# Never run from forks or mirrors: their tags must not exercise release
14+
# machinery, and nothing here may depend on another repository's state.
15+
if: github.repository == 'GaijinEntertainment/go-gerrit-mcp'
1316
runs-on: ubuntu-latest
1417
steps:
1518
- uses: actions/checkout@v7
@@ -18,6 +21,10 @@ jobs:
1821
- uses: actions/setup-go@v6
1922
with:
2023
go-version-file: go.mod
24+
# Release builds are hermetic: the Actions cache is writable from
25+
# any PR branch, so restoring it here would let a poisoned cache
26+
# entry reach the publishing build.
27+
cache: false
2128
- uses: docker/setup-qemu-action@v4
2229
- uses: docker/setup-buildx-action@v4
2330
- uses: docker/login-action@v4

0 commit comments

Comments
 (0)