-
-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create GitHub action to close issues automatically
- Loading branch information
1 parent
2f0c173
commit afbce1c
Showing
1 changed file
with
31 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,31 @@ | ||
name: close-third-party-issues | ||
|
||
on: | ||
issues: | ||
types: [opened] | ||
|
||
jobs: | ||
close-third-party-issues: | ||
name: Close third party issues | ||
runs-on: ubuntu-latest | ||
permissions: | ||
issues: write | ||
steps: | ||
- name: Close third party issues | ||
run: | | ||
set -e # Exit if one of commands exit with non-zero exit code | ||
set -u # Treat unset variables and parameters other than the special parameters ‘@’ or ‘*’ as an error | ||
set -o pipefail # Any command failed in the pipe fails the whole pipe | ||
author="$(gh issue view --repo "$REPO" "$ISSUE" --json author --jq '.author.login')" | ||
test "$author" = nikitabobko || \ | ||
{ gh issue edit --repo "$REPO" --add-label bin "$ISSUE" && \ | ||
gh issue close \ | ||
--repo "$REPO" \ | ||
--comment "Please don't open issues directly, use GitHub Discussions instead. See: https://github.com/nikitabobko/AeroSpace/issues/947" \ | ||
"$ISSUE"; } | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
REPO: ${{ github.repository }} | ||
ISSUE: ${{ github.event.issue.number }} |