Skip to content

Commit f0a805a

Browse files
authored
Add workflow to warn PRs targeting main (#586)
* Add workflow to warn PRs targeting main branch * Use pull_request_target and catch retargeted PRs
1 parent 58933e7 commit f0a805a

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

.github/workflows/warn_main_pr.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Warn PR targets main
2+
3+
on:
4+
pull_request_target:
5+
types: [opened, edited]
6+
branches:
7+
- main
8+
9+
jobs:
10+
warn:
11+
if: github.repository_owner == 'loopandlearn'
12+
runs-on: ubuntu-latest
13+
14+
permissions:
15+
pull-requests: write
16+
17+
steps:
18+
- name: Comment on PR
19+
uses: actions/github-script@v7
20+
with:
21+
script: |
22+
await github.rest.issues.createComment({
23+
owner: context.repo.owner,
24+
repo: context.repo.repo,
25+
issue_number: context.payload.pull_request.number,
26+
body: '⚠️ This PR targets the `main` branch. We do not accept PRs directly to `main` — please retarget your PR to the `dev` branch instead.'
27+
});

0 commit comments

Comments
 (0)