Skip to content

Commit 9f69a36

Browse files
committed
ci: gate main behind a stable ci-ok context and run real CI on release commits before pushing to protected main
1 parent 44166f2 commit 9f69a36

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
pull_request:
55
push:
66
branches: [main]
7+
workflow_dispatch:
78

89
permissions:
910
contents: read
@@ -42,3 +43,11 @@ jobs:
4243

4344
- name: Test
4445
run: uv run pytest tests/test_factory.py -v
46+
47+
# Single stable context for branch protection: matrix legs rename as Python versions rotate, this name never does.
48+
ci-ok:
49+
if: always()
50+
needs: [test]
51+
runs-on: ubuntu-latest
52+
steps:
53+
- run: test "${{ needs.test.result }}" = "success"

.github/workflows/release.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ jobs:
1919
permissions:
2020
contents: write
2121
id-token: write
22+
actions: write
2223
steps:
2324
- uses: actions/checkout@v7
2425
with:
@@ -92,6 +93,8 @@ jobs:
9293

9394
- name: Commit, tag, push
9495
if: steps.diff.outputs.changed == 'true' || github.event_name == 'workflow_dispatch'
96+
env:
97+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9598
run: |
9699
git config user.name "github-actions[bot]"
97100
git config user.email "github-actions[bot]@users.noreply.github.com"
@@ -100,7 +103,20 @@ jobs:
100103
git add pyproject.toml uv.lock src/roxy_sdk/version.py specs/openapi.json src/roxy_sdk/factory.py
101104
git commit -m "release: v$VERSION"
102105
git tag "v$VERSION"
106+
# Protected main requires the ci-ok context green on every pushed SHA, and a direct push can never carry one. So park the commit on a temp branch, run the real CI there via workflow_dispatch (GITHUB_TOKEN pushes trigger no workflows on their own), and push to main only after it reports green.
107+
SHA=$(git rev-parse HEAD)
108+
git push --force origin "HEAD:refs/heads/release-checks"
109+
gh workflow run ci.yml --ref release-checks
110+
RUN_ID=""
111+
for _ in $(seq 1 24); do
112+
sleep 5
113+
RUN_ID=$(gh run list --workflow=ci.yml --branch=release-checks --limit 5 --json databaseId,headSha --jq "[.[] | select(.headSha == \"$SHA\")][0].databaseId // empty")
114+
[ -n "$RUN_ID" ] && break
115+
done
116+
[ -n "$RUN_ID" ] || { echo "dispatched CI run never appeared for $SHA"; exit 1; }
117+
gh run watch "$RUN_ID" --exit-status
103118
git push --follow-tags
119+
git push origin --delete release-checks || true
104120
105121
- name: Create GitHub release
106122
if: steps.diff.outputs.changed == 'true' || github.event_name == 'workflow_dispatch'

0 commit comments

Comments
 (0)