Next Release #425
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: PR Target Branch Check | |
| on: | |
| pull_request_target: | |
| types: [opened, edited] | |
| jobs: | |
| check-target: | |
| runs-on: ubuntu-latest | |
| # The default GITHUB_TOKEN is read-only; without these the addLabels call | |
| # 403s ("Resource not accessible by integration") and the job could never | |
| # succeed — even on a genuinely wrong-base PR (audit finding). | |
| permissions: | |
| pull-requests: write | |
| issues: write | |
| # Only flag PRs targeting main that don't come from develop. develop→main | |
| # PRs are the maintainer release path, and release-please's version-bump | |
| # PRs (head `release-please--branches--main--…`) legitimately target main | |
| # too — they were flagged (then 403'd) on every release, e.g. #343/#349. | |
| if: >- | |
| github.event.pull_request.base.ref == 'main' && | |
| github.event.pull_request.head.ref != 'develop' && | |
| !startsWith(github.event.pull_request.head.ref, 'release-please--') | |
| steps: | |
| - name: Add wrong-base label and comment | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const pr = context.payload.pull_request; | |
| await github.rest.issues.addLabels({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: pr.number, | |
| labels: ['wrong-base'], | |
| }); | |
| const body = `Thanks for the PR! It looks like this targets \`main\`, but contributor PRs should target the **\`develop\`** branch. | |
| \`main\` is reserved for stable releases (only \`develop\` → \`main\` PRs cut by maintainers via release-please). | |
| To fix: | |
| 1. Click **Edit** at the top right of this PR | |
| 2. Change the base branch from \`main\` to \`develop\` | |
| See \`.github/workflows/cd.yml\` for the release flow.`; | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: pr.number, | |
| body, | |
| }); |