From edbc22e02f54bc9fb119a8f89ab7370b9ee78f3d Mon Sep 17 00:00:00 2001 From: Kamran Ahmed Date: Fri, 10 May 2024 16:44:14 +0100 Subject: [PATCH] Close empty issues --- .github/workflows/close-empty-issue.yml | 29 +++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/workflows/close-empty-issue.yml diff --git a/.github/workflows/close-empty-issue.yml b/.github/workflows/close-empty-issue.yml new file mode 100644 index 000000000000..7637004e3891 --- /dev/null +++ b/.github/workflows/close-empty-issue.yml @@ -0,0 +1,29 @@ +name: Close Issue if Empty +on: + issues: + types: [ opened, edited ] +jobs: + close-empty-issue: + runs-on: ubuntu-latest + steps: + - name: Close Issue if Empty + uses: actions/github-script@v3 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const issue = context.payload.issue; + if (issue.body.trim() === '') { + await github.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: issue.number, + body: 'Closing this issue because it is empty. Feel free to reopen with more details if you have any questions or need help.', + }); + + await github.issues.update({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: issue.number, + state: 'closed', + }); + } \ No newline at end of file