-
Notifications
You must be signed in to change notification settings - Fork 277
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: Auto Close Issues if Not Starred | ||
|
||
on: | ||
issues: | ||
types: [opened] | ||
|
||
jobs: | ||
close_issue: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check if user has starred the repo | ||
id: check_star | ||
run: | | ||
ISSUE_USER=$(jq -r '.issue.user.login' < $GITHUB_EVENT_PATH) | ||
STARRED=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | ||
"https://api.github.com/user/starred/${{ github.repository }}" | \ | ||
jq -r '.[].login' | grep -c "^$ISSUE_USER$" || true) | ||
echo "::set-output name=starred::$STARRED" | ||
- name: Close issue if not starred | ||
if: steps.check_star.outputs.starred == '0' | ||
run: | | ||
ISSUE_NUMBER=$(jq -r '.issue.number' < $GITHUB_EVENT_PATH) | ||
curl -s -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | ||
-H "Accept: application/vnd.github.v3+json" \ | ||
https://api.github.com/repos/${{ github.repository }}/issues/$ISSUE_NUMBER/comments \ | ||
-d '{"body":"白嫖随便拿,但不接受无star的提问。本提问将自动关闭。Please star the project before submitting an issue."}' | ||
curl -s -X PATCH -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | ||
-H "Accept: application/vnd.github.v3+json" \ | ||
https://api.github.com/repos/${{ github.repository }}/issues/$ISSUE_NUMBER \ | ||
-d '{"state":"closed"}' |