-
-
Notifications
You must be signed in to change notification settings - Fork 540
56 lines (45 loc) · 1.89 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
56
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 main
run: |
comment="
You cannot directly commit to the [\`main\`](https://github.com/Atlas) branch, read the contribution guide and only commit to [\`dev\`](https://github.com/Atlas/tree/dev).
**Contribution Guidelines:** https://docs.atlasos.net/contributions
"
exclude_labels="
bypass
auto-pr
translations
readme
"
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 main, but it is being bypassed due to its labels."
else
if [ $(gh pr view $pr_number --json baseRefName --jq '.baseRefName') == 'main' ]; then
echo "Closing pull request #$pr_number as it directly commits to main..."
gh pr close $pr_number --comment "$comment"
fi
fi
done
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}