Skip to content

Documentation v0.3.0 #52

Documentation v0.3.0

Documentation v0.3.0 #52

Workflow file for this run

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
"
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 }}