Mark stale issues and pull requests #1329
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Mark stale issues and pull requests | |
| on: | |
| schedule: | |
| - cron: "0 0 * * *" | |
| permissions: | |
| contents: read | |
| jobs: | |
| stale: | |
| permissions: | |
| issues: write # for actions/stale to close stale issues | |
| pull-requests: write # for actions/stale to close stale PRs | |
| runs-on: ubuntu-24.04 | |
| outputs: | |
| staled_prs: ${{ steps.filter-prs.outputs.result }} | |
| steps: | |
| - name: Mark stale issues and pull requests | |
| uses: actions/stale@v10 | |
| id: stale | |
| with: | |
| repo-token: ${{ secrets.GITHUB_TOKEN }} | |
| stale-pr-message: "This PR has been inactive for long enough to be automatically marked as stale. This means it is at risk of being auto closed in ~7 days. Please address any outstanding review items and ensure your PR is finished - if both are true, and you have auto-staled anyway, you need to actively ask maintainers (by pinging them in the /tg/station Discord) to (re)review or merge your PR. If no maintainer responds to your request, you may wish to close this PR yourself while you seek maintainer comment, as you will later be able to reopen the PR yourself." | |
| stale-issue-message: "This issue has been marked for cleanup and will be automatically closed in ~14 days. If there is evidence that the issue still occurs, leave a comment with it attached and contact an issue manager or maintainer to have the label removed." | |
| days-before-stale: 7 | |
| days-before-close: 7 | |
| days-before-issue-stale: 14 | |
| days-before-issue-close: 14 | |
| stale-pr-label: "Stale" | |
| stale-issue-label: "Stale" | |
| any-of-issue-labels: "Cleanup Flagged,🤖 Flaky Test Report" | |
| remove-issue-stale-when-updated: false | |
| exempt-issue-labels: "RED LABEL" | |
| exempt-pr-labels: "RED LABEL,Good First PR" | |
| operations-per-run: 300 | |
| - name: Filter staled pull requests for announcement | |
| id: filter-prs | |
| uses: actions/github-script@v9 | |
| env: | |
| input: ${{steps.stale.outputs.staled-issues-prs}} | |
| with: | |
| script: | | |
| return JSON.parse(process.env.input) | |
| .filter(issue => !!issue.pull_request) | |
| .map(pr => ({ | |
| title: pr.title, | |
| number: pr.number, | |
| html_url: pr.pull_request.html_url, | |
| })); | |
| announce: | |
| runs-on: ubuntu-24.04 | |
| needs: stale | |
| if: ${{ needs.stale.outputs.staled_prs != '[]' }} | |
| strategy: | |
| matrix: | |
| pull_request: ${{ fromJSON(needs.stale.outputs.staled_prs) }} | |
| steps: | |
| - name: "Check for DISCORD_WEBHOOK" | |
| id: secrets_set | |
| env: | |
| ENABLER_SECRET: ${{ secrets.DISCORD_WEBHOOK }} | |
| run: | | |
| unset SECRET_EXISTS | |
| if [ -n "$ENABLER_SECRET" ]; then SECRET_EXISTS=true ; fi | |
| echo "SECRETS_ENABLED=$SECRET_EXISTS" >> $GITHUB_OUTPUT | |
| - name: Send Discord notification | |
| uses: tgstation/discord-notify@main | |
| if: > | |
| steps.secrets_set.outputs.SECRETS_ENABLED | |
| with: | |
| webhook_url: ${{ secrets.DISCORD_WEBHOOK }} | |
| title: ${{ matrix.pull_request.title }} | |
| message: ${{ format('**Pull Request \#{0} automatically marked as stale.**', matrix.pull_request.number) }} | |
| include_image: false | |
| show_author: false | |
| avatar_url: https://avatars.githubusercontent.com/u/1363778?s=200&v=4 | |
| username: GitHub | |
| title_url: "${{ matrix.pull_request.html_url }}" |