Skip to content

Commit

Permalink
Create GitHub action to close issues automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitabobko committed Feb 14, 2025
1 parent 2f0c173 commit afbce1c
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/close-third-party-issues.yml
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 }}

0 comments on commit afbce1c

Please sign in to comment.