|
| 1 | +# SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors |
| 2 | +# SPDX-License-Identifier: MIT |
| 3 | +name: Issue triage reminders |
| 4 | + |
| 5 | +on: |
| 6 | + schedule: |
| 7 | + - cron: '0 2 * * *' # 02:00 UTC daily |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +permissions: |
| 11 | + issues: write |
| 12 | + contents: read |
| 13 | + |
| 14 | +jobs: |
| 15 | + remind: |
| 16 | + runs-on: ubuntu-latest |
| 17 | + steps: |
| 18 | + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 |
| 19 | + - name: Load triage config via yq |
| 20 | + id: cfg |
| 21 | + run: | |
| 22 | + TRIAGE=$(yq eval -o=json '.triage' .github/triage-issue-bot-config.yml) |
| 23 | + printf "triage<<EOF\n%s\nEOF\n" "$TRIAGE" >> $GITHUB_OUTPUT |
| 24 | +
|
| 25 | + - name: Find stale issues |
| 26 | + id: search |
| 27 | + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 |
| 28 | + with: |
| 29 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 30 | + script: | |
| 31 | + const cfg = JSON.parse(process.env.INPUT_TRIAGE || '{}'); |
| 32 | + const since = new Date( |
| 33 | + Date.now() - cfg.first_ping_after_days * 24*3600*1000 |
| 34 | + ).toISOString(); |
| 35 | +
|
| 36 | + const q = [ |
| 37 | + `repo:${context.repo.owner}/${context.repo.repo}`, |
| 38 | + `is:issue is:open`, |
| 39 | + `updated:<${since}` |
| 40 | + ].join(' '); |
| 41 | +
|
| 42 | + const res = await github.rest.search.issuesAndPullRequests({ |
| 43 | + q, per_page: 100 |
| 44 | + }); |
| 45 | + core.setOutput('issues', JSON.stringify( |
| 46 | + res.data.items.map(i => i.number) |
| 47 | + )); |
| 48 | + env: |
| 49 | + INPUT_TRIAGE: ${{ steps.cfg.outputs.triage }} |
| 50 | + |
| 51 | + - name: Ping & rotate labels |
| 52 | + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 |
| 53 | + with: |
| 54 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 55 | + script: | |
| 56 | + const issues = JSON.parse(process.env.ISSUES || '[]'); |
| 57 | + const cfg = JSON.parse(process.env.INPUT_TRIAGE || '{}'); |
| 58 | +
|
| 59 | + for (const num of issues) { |
| 60 | + const { data: issue } = await github.rest.issues.get({ |
| 61 | + ...context.repo, issue_number: num |
| 62 | + }); |
| 63 | +
|
| 64 | + const labels = issue.labels.map(l => l.name); |
| 65 | + if (labels.some(n => !/^reminder-\d+$/.test(n))) continue; |
| 66 | +
|
| 67 | + const cutoff = new Date( |
| 68 | + Date.now() - cfg.repeat_every_days * 24*3600*1000 |
| 69 | + ); |
| 70 | + if (new Date(issue.updated_at) > cutoff) continue; |
| 71 | +
|
| 72 | + const remLabel = labels.find(n => /^reminder-\d+$/.test(n)); |
| 73 | + const current = remLabel ? parseInt(remLabel.split('-')[1],10) : 0; |
| 74 | + const next = current + 1; |
| 75 | +
|
| 76 | + const mention = next >= cfg.escalation_ping |
| 77 | + ? '\n\n' + (cfg.escalation_mentions || []).join(' ') |
| 78 | + : ''; |
| 79 | +
|
| 80 | + await github.rest.issues.createComment({ |
| 81 | + ...context.repo, |
| 82 | + issue_number: num, |
| 83 | + body: `🔔 Friendly reminder – please triage this issue.${mention}` |
| 84 | + }); |
| 85 | +
|
| 86 | + if (remLabel) { |
| 87 | + await github.rest.issues.removeLabel({ |
| 88 | + ...context.repo, |
| 89 | + issue_number: num, |
| 90 | + name: remLabel |
| 91 | + }).catch(() => {}); |
| 92 | + } |
| 93 | + await github.rest.issues.addLabels({ |
| 94 | + ...context.repo, |
| 95 | + issue_number: num, |
| 96 | + labels: [`reminder-${next}`] |
| 97 | + }); |
| 98 | + } |
| 99 | + env: |
| 100 | + ISSUES: ${{ steps.search.outputs.issues }} |
| 101 | + INPUT_TRIAGE: ${{ steps.cfg.outputs.triage }} |
0 commit comments