-
Notifications
You must be signed in to change notification settings - Fork 4k
55 lines (44 loc) · 1.76 KB
/
pr-base-check.yml
File metadata and controls
55 lines (44 loc) · 1.76 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
name: PR Base Branch Check
on:
pull_request:
types: [opened, edited, synchronize]
branches:
- main
permissions:
pull-requests: write
contents: read
jobs:
check-base-branch:
runs-on: ubuntu-latest
if: github.event.pull_request.base.ref == 'main'
steps:
- name: Comment on PR
uses: actions/github-script@v7
with:
script: |
const message = `👋 Hi there!
It looks like this PR is targeting the \`main\` branch. To help maintain our development workflow, please change the base reference to \`next\` instead.
__If this is a bug fix that requires a patch release __ (e.g., a critical bug that needs to be fixed before the next release)__, please leave the base branch as \`main\`.__
You can change this by:
1. Clicking the "Edit" button next to the PR title
2. Changing the base branch from \`main\` to \`next\`
3. Clicking "Update pull request"
Thanks for your contribution! 🚀`;
// Check if we've already commented
const comments = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const botComment = comments.data.find(comment =>
comment.user.type === 'Bot' &&
comment.body.includes('please change the base reference to')
);
if (!botComment) {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: message
});
}