Skip to content

Commit 620d219

Browse files
committed
Prevent accidental merges directly to main with same script as in main repo
1 parent 67d1a9a commit 620d219

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: PR Base Branch Check
2+
3+
on:
4+
pull_request:
5+
types: [opened, edited, synchronize]
6+
7+
jobs:
8+
check-base-branch:
9+
name: Check PR Base Branch
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Check if PR targets main instead of develop
13+
if: github.event.pull_request.base.ref == 'main' && github.event.pull_request.head.ref != 'develop'
14+
uses: actions/github-script@v7
15+
with:
16+
script: |
17+
const message = `⚠️ **WARNING: This PR targets \`main\` instead of \`develop\`**
18+
19+
This PR is targeting \`main\` which will trigger a production deployment when merged.
20+
21+
If this is a regular feature/fix PR, please change the base branch to \`develop\`.
22+
If this is intentional (e.g., hotfix), you can ignore this warning.
23+
24+
Current base: \`${context.payload.pull_request.base.ref}\`
25+
Recommended base: \`develop\``;
26+
27+
await github.rest.issues.createComment({
28+
owner: context.repo.owner,
29+
repo: context.repo.repo,
30+
issue_number: context.payload.pull_request.number,
31+
body: message
32+
});
33+
34+
core.warning('PR targets main branch - please verify this is intentional');

0 commit comments

Comments
 (0)