-
Notifications
You must be signed in to change notification settings - Fork 56
55 lines (44 loc) · 1.9 KB
/
filter.yaml
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: Pull Request Filter
on: pull_request_target
jobs:
filter:
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Label pull request
uses: actions/labeler@v4
- name: Close pull requests that directly commit to master
run: |
comment="
You can not directly commit to the [\`master\`](https://github.com/Atlas-OS/docs) branch, read the contribution guide and only commit to [\`dev\`](https://github.com/Atlas-OS/docs/tree/dev).
**Contribution Guidelines:** https://docs.atlasos.net/contributions
"
exclude_labels="
bypass
auto-pr
dependencies
"
no_run=false
for pr_number in $(gh pr list --json number --jq '.[].number'); do
echo "Processing pull request: #$pr_number"
for label in $(gh pr view $pr_number --json labels --jq '.labels[].name'); do
if [[ "$exclude_labels" == *"$label"* ]]; then
no_run=true
break
fi
done
if [ "$no_run" == "true" ]; then
echo "Pull request #$pr_number merges into master, but it is being bypassed due to its labels."
else
if [ $(gh pr view $pr_number --json baseRefName --jq '.baseRefName') == 'master' ]; then
echo "Closing pull request #$pr_number as it directly commits to master..."
gh pr close $pr_number --comment "$comment"
fi
fi
done
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}