Skip to content

Commit adfd7fe

Browse files
committed
feat: add verification for latest green CI commit
1 parent 3c08817 commit adfd7fe

3 files changed

Lines changed: 65 additions & 13 deletions

File tree

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ jobs:
2323
env:
2424
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2525

26+
- name: Verify compiled workflows are committed
27+
run: git diff --exit-code -- .github/workflows workflows
28+
2629
add-local-source:
2730
runs-on: ubuntu-latest
2831
needs: [compile]

.github/workflows/release.lock.yml

Lines changed: 37 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/release.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ jobs:
3131
needs: ["pre_activation", "activation"]
3232
runs-on: ubuntu-latest
3333
permissions:
34+
actions: read
3435
contents: write
3536
outputs:
3637
release_id: ${{ steps.create_release.outputs.release_id }}
@@ -44,6 +45,30 @@ jobs:
4445
env:
4546
RELEASE_TARGET: ${{ inputs.target }}
4647

48+
- name: Verify target is latest green CI commit on main
49+
env:
50+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51+
run: |
52+
set -euo pipefail
53+
54+
target_sha=$(git rev-parse HEAD)
55+
latest_green_sha=$(gh api \
56+
"/repos/$GITHUB_REPOSITORY/actions/workflows/ci.yml/runs?branch=main&status=completed&per_page=20" \
57+
--jq '.workflow_runs[] | select(.conclusion == "success") | .head_sha' \
58+
| head -n 1)
59+
60+
if [[ -z "$latest_green_sha" ]]; then
61+
echo "No successful CI run found for main." >&2
62+
exit 1
63+
fi
64+
65+
if [[ "$target_sha" != "$latest_green_sha" ]]; then
66+
echo "Release target must match the latest successful CI run on main." >&2
67+
echo "Checked out target: $target_sha" >&2
68+
echo "Latest green main SHA: $latest_green_sha" >&2
69+
exit 1
70+
fi
71+
4772
- name: Set up gh-aw CLI
4873
uses: github/gh-aw-actions/setup-cli@f8495a686e66770ae977f82732f34d7340ee42a4 # v0.72.1
4974
with:

0 commit comments

Comments
 (0)