-
-
Notifications
You must be signed in to change notification settings - Fork 431
41 lines (35 loc) · 1.02 KB
/
Copy pathblock-pr-to-master.yml
File metadata and controls
41 lines (35 loc) · 1.02 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
name: Block PR to master
on:
pull_request:
types:
- opened
- reopened
- synchronize
- edited
branches:
- master
permissions:
pull-requests: write
issues: write
jobs:
close-pr-to-master:
name: Close PR to master
runs-on: ubuntu-latest
steps:
- name: Close pull request targeting master
uses: actions/github-script@v7
with:
script: |
const pullRequest = context.payload.pull_request;
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pullRequest.number,
body: 'Pull requests directly to `master` are not allowed. Please open your PR against `develop` or the correct target branch.'
});
await github.rest.pulls.update({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pullRequest.number,
state: 'closed'
});