forked from github/awesome-copilot
-
Notifications
You must be signed in to change notification settings - Fork 0
35 lines (31 loc) · 1.08 KB
/
check-pr-target.yml
File metadata and controls
35 lines (31 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
name: Check PR Target Branch
on:
pull_request:
branches: [main]
types: [opened]
permissions:
pull-requests: write
jobs:
check-target:
runs-on: ubuntu-latest
steps:
- name: Reject PR targeting main
uses: actions/github-script@v7
with:
script: |
const body = [
'⚠️ **This PR targets `main`, but PRs should target `staged`.**',
'',
'The `main` branch is auto-published from `staged` and should not receive direct PRs.',
'Please close this PR and re-open it against the `staged` branch.',
'',
'You can change the base branch using the **Edit** button at the top of this PR,',
'or run: `gh pr edit ${{ github.event.pull_request.number }} --base staged`'
].join('\n');
await github.rest.pulls.createReview({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number,
event: 'REQUEST_CHANGES',
body
});