Skip to content

Commit 9d21154

Browse files
authored
release: promote develop to main (#12)
Ships the pr-guard workflow to `main`.
2 parents 394f6dd + 8403eb2 commit 9d21154

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

.github/workflows/pr-guard.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: pr-guard
2+
3+
on:
4+
pull_request_target:
5+
types: [opened, reopened]
6+
7+
permissions: {}
8+
9+
jobs:
10+
collaborators-only:
11+
name: collaborators-only
12+
runs-on: ubuntu-latest
13+
permissions:
14+
pull-requests: write
15+
steps:
16+
- name: Close pull requests from non-collaborators
17+
env:
18+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19+
ASSOC: ${{ github.event.pull_request.author_association }}
20+
LOGIN: ${{ github.event.pull_request.user.login }}
21+
PR: ${{ github.event.pull_request.number }}
22+
REPO: ${{ github.repository }}
23+
run: |
24+
if [ "$LOGIN" = "dependabot[bot]" ]; then
25+
echo "Dependabot is allowed."
26+
exit 0
27+
fi
28+
case "$ASSOC" in
29+
OWNER|MEMBER|COLLABORATOR)
30+
echo "Author is a collaborator."
31+
;;
32+
*)
33+
gh pr comment "$PR" --repo "$REPO" --body "Thanks for your interest. This project does not accept unsolicited pull requests — contributions are invitation-only (see CONTRIBUTING.md). If you found a bug, please open an issue instead: we genuinely appreciate bug reports."
34+
gh pr close "$PR" --repo "$REPO"
35+
;;
36+
esac

0 commit comments

Comments
 (0)