From 04cf4e997fd36dc008f19a0aa1449ff5a35b490a Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Tue, 6 Feb 2024 17:19:43 +0100 Subject: [PATCH] chore: close issues with no user response (#1804) * Create issues-no-response.yml * Update issues-no-response.yml * Create on-comment-remove-label.yml * Update on-comment-remove-label.yml * clean up * Improved conciseness and fixed spelling mistake. Co-authored-by: Luka S * fix: don't remove label for the automatic message (#9) * Update issue-comment.yml * Update issue-comment.yml * enable message when issue gets closed Co-authored-by: Luka S --------- Co-authored-by: Luka S --- .github/workflows/daily.yml | 25 ++++++++++++++++++ .github/workflows/issue-comment.yml | 40 +++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 .github/workflows/daily.yml create mode 100644 .github/workflows/issue-comment.yml diff --git a/.github/workflows/daily.yml b/.github/workflows/daily.yml new file mode 100644 index 000000000..958eed2cc --- /dev/null +++ b/.github/workflows/daily.yml @@ -0,0 +1,25 @@ +name: "Daily Maintenance" +on: + schedule: + - cron: "0 0 * * *" + +jobs: + close-issues: + runs-on: ubuntu-latest + permissions: + issues: write + pull-requests: write + steps: + - uses: actions/stale@v5 + with: + days-before-issue-stale: 21 + days-before-issue-close: 7 + stale-issue-label: "stale" + stale-issue-message: "This issue requires additional information in order to be resolved. However, there hasn't been any response within the last 3 weeks.\n If this issue still persists, please provide the requested information. This issue will be automatically closed in one week if there is no response." + close-issue-message: "This issue was closed because it has been inactive for 4 weeks, and still requires information in order to be resolved." + days-before-pr-stale: -1 + days-before-pr-close: -1 + remove-stale-when-updated: true + any-of-labels: "waiting for user response" + labels-to-remove-when-unstale: "waiting for user response,stale" + repo-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/issue-comment.yml b/.github/workflows/issue-comment.yml new file mode 100644 index 000000000..8a62b924e --- /dev/null +++ b/.github/workflows/issue-comment.yml @@ -0,0 +1,40 @@ +name: "Issue Comment" +on: + issue_comment: + types: [ created ] + +jobs: + remove-waiting-for-user-reponse: + runs-on: ubuntu-latest + permissions: + issues: write + pull-requests: write + steps: + - name: Check labels of issue + id: check_labels + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const { data: issue } = await github.rest.issues.get({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number + }); + const isStale = issue.labels.some(label => label.name === 'stale'); + const waitingResponse = issue.labels.some(label => label.name === 'waiting for user response'); + return !isStale && waitingResponse; + # only remove the label if the issue is not stale, this prevents that this + # action removes the label when the automatic reminder message gets sent. + - name: Remove `waiting for user response` label if exists + if: steps.check_labels.outputs.result == 'true' + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + await github.rest.issues.removeLabel({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + name: ["waiting for user response"] + }); \ No newline at end of file