File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1010permissions :
1111 contents : write
1212 pull-requests : write
13+ statuses : write
1314
1415concurrency :
1516 group : release-sync
3334
3435 - name : Open or update PR release -> main
3536 env :
36- # PRs created with GITHUB_TOKEN do not trigger other workflows, so the
37- # main-source-guard check would never run on this PR. Set the optional
38- # secret RELEASE_PR_TOKEN (PAT or app token) to make it run.
37+ # Needs "Allow GitHub Actions to create and approve pull requests" in the
38+ # repository's Actions settings. RELEASE_PR_TOKEN is optional.
3939 GH_TOKEN : ${{ secrets.RELEASE_PR_TOKEN || github.token }}
4040 run : |
4141 set -eu
5151 else
5252 gh pr create --head release --base main --title "$title" --body "$body"
5353 fi
54+
55+ # A PR opened with GITHUB_TOKEN triggers no workflows, so main-source-guard
56+ # never runs on it. Report the guard's verdict for the release commit here:
57+ # this job just generated it from develop, which is exactly what the guard
58+ # requires. A status set with GITHUB_TOKEN satisfies a required check.
59+ - name : Mark release as passing the main source guard
60+ env :
61+ GH_TOKEN : ${{ github.token }}
62+ run : |
63+ set -eu
64+ if ! git rev-parse -q --verify refs/heads/release >/dev/null; then exit 0; fi
65+ gh api "repos/${GITHUB_REPOSITORY}/statuses/$(git rev-parse release)" \
66+ -f state=success -f context=only-release-into-main \
67+ -f description="generated from develop ${GITHUB_SHA::7} by release-sync"
Original file line number Diff line number Diff line change @@ -12,11 +12,13 @@ ignored and overwritten.
1212 whose tree is the develop tree minus the files below. This happens even when nothing
1313 is dropped. It is a no-op only if ` release ` already has that tree and that parent.
1414 The push uses ` --force-with-lease ` pinned to the remote sha the run observed.
15- 2 . The workflow opens (or updates) a pull request ` release ` -> ` main ` . PRs created with
16- the default ` GITHUB_TOKEN ` do not trigger other workflows, so ` main-source-guard `
17- would not run on them. To make it run, add a repository secret ` RELEASE_PR_TOKEN `
18- (a PAT or GitHub App token with pull-request write access); the workflow uses it
19- when present and falls back to ` github.token ` otherwise.
15+ 2 . The workflow opens (or updates) a pull request ` release ` -> ` main ` with the default
16+ ` GITHUB_TOKEN ` . This needs the repository setting * Actions -> General -> Allow GitHub
17+ Actions to create and approve pull requests* . A PR opened with ` GITHUB_TOKEN `
18+ triggers no workflows, so ` main-source-guard ` would never run on it; the workflow
19+ therefore sets the ` only-release-into-main ` commit status on the release commit
20+ itself, which satisfies the required check. No PAT is needed; an optional
21+ ` RELEASE_PR_TOKEN ` secret is used for the PR step when present.
20223 . Merging that PR is the only way to change ` main ` . ` main-source-guard.yml ` fails
2123 any PR into ` main ` whose head is not ` release ` .
22244 . On push to ` main ` , ` pages.yml ` deploys ` docs/guide/ ` to GitHub Pages.
You can’t perform that action at this time.
0 commit comments