Skip to content

Commit f505f90

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 ae5ace6 commit f505f90

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
@@ -47,3 +48,11 @@ jobs:
4748
run: dotnet test -c Release --no-build
4849
env:
4950
ROXY_API_KEY: ${{ secrets.ROXY_API_KEY }}
51+
52+
# Single stable context for branch protection, uniform across all SDK repos even where the CI job is not matrixed.
53+
ci-ok:
54+
if: always()
55+
needs: [build]
56+
runs-on: ubuntu-latest
57+
steps:
58+
- run: test "${{ needs.build.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:
@@ -95,14 +96,29 @@ jobs:
9596

9697
- name: Commit, tag, push
9798
if: steps.diff.outputs.changed == 'true' || github.event_name == 'workflow_dispatch'
99+
env:
100+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
98101
run: |
99102
git config user.name "github-actions[bot]"
100103
git config user.email "github-actions[bot]@users.noreply.github.com"
101104
VERSION=${{ steps.bump.outputs.version }}
102105
git add specs/openapi.json src/ README.md AGENTS.md docs/llms-full.txt tests/RoxyApi.Tests/Generated
103106
git commit -m "release: v$VERSION"
104107
git tag "v$VERSION"
108+
# 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.
109+
SHA=$(git rev-parse HEAD)
110+
git push --force origin "HEAD:refs/heads/release-checks"
111+
gh workflow run ci.yml --ref release-checks
112+
RUN_ID=""
113+
for _ in $(seq 1 24); do
114+
sleep 5
115+
RUN_ID=$(gh run list --workflow=ci.yml --branch=release-checks --limit 5 --json databaseId,headSha --jq "[.[] | select(.headSha == \"$SHA\")][0].databaseId // empty")
116+
[ -n "$RUN_ID" ] && break
117+
done
118+
[ -n "$RUN_ID" ] || { echo "dispatched CI run never appeared for $SHA"; exit 1; }
119+
gh run watch "$RUN_ID" --exit-status
105120
git push --follow-tags
121+
git push origin --delete release-checks || true
106122
107123
- name: Create GitHub release
108124
if: steps.diff.outputs.changed == 'true' || github.event_name == 'workflow_dispatch'

0 commit comments

Comments
 (0)