diff --git a/.github/workflows/lock-spams.yml b/.github/workflows/lock-spams.yml new file mode 100644 index 0000000..d87ec62 --- /dev/null +++ b/.github/workflows/lock-spams.yml @@ -0,0 +1,25 @@ +name: Close and lock spam issues + +on: + issues: + types: [labeled] + workflow_dispatch: + +jobs: + handle_spam: + if: github.event.label.name == 'spam' + runs-on: ubuntu-latest + permissions: + issues: write + steps: + - name: Close the issue + run: gh issue close "$ISSUE_NUM" --reason "not planned" + - name: Lock the issue + run: | + if [ "$(gh api repos/"$GH_REPO"/issues/"$ISSUE_NUM" --jq '.locked')" = "false" ]; then + gh issue lock "$ISSUE_NUM" --reason "spam" + fi + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_REPO: ${{ github.repository }} + ISSUE_NUM: ${{ github.event.issue.number }}