|
17 | 17 | runs-on: ubuntu-latest |
18 | 18 | permissions: |
19 | 19 | contents: write |
| 20 | + actions: write |
20 | 21 | steps: |
21 | 22 | - uses: actions/checkout@v7 |
22 | 23 | with: |
@@ -78,14 +79,29 @@ jobs: |
78 | 79 |
|
79 | 80 | - name: Commit, tag, push |
80 | 81 | if: steps.diff.outputs.changed == 'true' || github.event_name == 'workflow_dispatch' |
| 82 | + env: |
| 83 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
81 | 84 | run: | |
82 | 85 | git config user.name "github-actions[bot]" |
83 | 86 | git config user.email "github-actions[bot]@users.noreply.github.com" |
84 | 87 | VERSION="${{ steps.bump.outputs.version }}" |
85 | 88 | git add composer.json package.json src/Version.php specs/openapi.json src/Roxy.php src/Generated tests/Generated README.md AGENTS.md |
86 | 89 | git commit -m "release: v$VERSION" |
87 | 90 | git tag "v$VERSION" |
| 91 | + # 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. |
| 92 | + SHA=$(git rev-parse HEAD) |
| 93 | + git push --force origin "HEAD:refs/heads/release-checks" |
| 94 | + gh workflow run ci.yml --ref release-checks |
| 95 | + RUN_ID="" |
| 96 | + for _ in $(seq 1 24); do |
| 97 | + sleep 5 |
| 98 | + RUN_ID=$(gh run list --workflow=ci.yml --branch=release-checks --limit 5 --json databaseId,headSha --jq "[.[] | select(.headSha == \"$SHA\")][0].databaseId // empty") |
| 99 | + [ -n "$RUN_ID" ] && break |
| 100 | + done |
| 101 | + [ -n "$RUN_ID" ] || { echo "dispatched CI run never appeared for $SHA"; exit 1; } |
| 102 | + gh run watch "$RUN_ID" --exit-status |
88 | 103 | git push --follow-tags |
| 104 | + git push origin --delete release-checks || true |
89 | 105 |
|
90 | 106 | - name: Create GitHub release |
91 | 107 | if: steps.diff.outputs.changed == 'true' || github.event_name == 'workflow_dispatch' |
|
0 commit comments