I'm going to write something more robust using PyGitHub.
Unified · Split
| @@ -1,32 +0,0 @@ | ||
| 1 | −name: Close Unlabeled Issues | |
| 2 | − | |
| 3 | −on: | |
| 4 | − schedule: | |
| 5 | − - cron: "0 * * * *" | |
| 6 | − workflow_dispatch: | |
| 7 | − | |
| 8 | −jobs: | |
| 9 | − close-unlabeled-issue: | |
| 10 | − runs-on: ubuntu-latest | |
| 11 | − steps: | |
| 12 | − - name: Check for labels and close if unlabeled | |
| 13 | − uses: actions/github-script@v6 | |
| 14 | − with: | |
| 15 | − github-token: ${{secrets.GITHUB_TOKEN}} | |
| 16 | − script: | | |
| 17 | − const issue = context.payload.issue; | |
| 18 | − if (issue.labels.length === 0) { | |
| 19 | − const issueNumber = issue.number; | |
| 20 | − await github.rest.issues.update({ | |
| 21 | − owner: context.repo.owner, | |
| 22 | − repo: context.repo.repo, | |
| 23 | − issue_number: issueNumber, | |
| 24 | − state: 'closed' | |
| 25 | − }); | |
| 26 | − await github.rest.issues.createComment({ | |
| 27 | − owner: context.repo.owner, | |
| 28 | − repo: context.repo.repo, | |
| 29 | − issue_number: issueNumber, | |
| 30 | − body: 'This issue has been automatically closed because it was created without using an issue template. Please reopen your issue using one of the following issue templates:\n\nhttps://github.com/zed-industries/zed/issues/new/choose' | |
| 31 | − }); | |
| 32 | − } | |