Skip to content

Close stale issues and PRs #138

Close stale issues and PRs

Close stale issues and PRs #138

Workflow file for this run

name: 'Close stale issues and PRs'
on:
schedule:
- cron: '30 1 * * *' # every day at 1:30 UTC
jobs:
stale:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
contents: write
steps:
- name: Generate stale messages
id: messages
run: |
EXEMPT_PR_LABELS='wip,blocked'
STALE_TEMPLATE='This [type] is stale because it has been open [stale-days] days with no activity. It will be closed in [close-days] days if no further activity occurs. Tag your issue with blocked or [exempt-pr-labels] to keep it open.'
CLOSE_TEMPLATE='Closing this [type] due to prolonged inactivity.'
STALE_ISSUE_MSG="${STALE_TEMPLATE//\[type\]/issue}"
STALE_ISSUE_MSG="${STALE_ISSUE_MSG//\[stale-days\]/30}"
STALE_ISSUE_MSG="${STALE_ISSUE_MSG//\[close-days\]/5}"
CLOSE_ISSUE_MSG="${CLOSE_TEMPLATE//\[type\]/issue}"
CLOSE_ISSUE_MSG="${CLOSE_ISSUE_MSG//\[exempt-pr-labels\]/$EXEMPT_PR_LABELS}"
STALE_PR_MSG="${STALE_TEMPLATE//\[type\]/PR}"
STALE_PR_MSG="${STALE_PR_MSG//\[stale-days\]/45}"
STALE_PR_MSG="${STALE_PR_MSG//\[close-days\]/10}"
CLOSE_PR_MSG="${CLOSE_TEMPLATE//\[type\]/PR}"
CLOSE_PR_MSG="${CLOSE_PR_MSG//\[exempt-pr-labels\]/$EXEMPT_PR_LABELS}"
echo "exempt-pr-labels=$EXEMPT_PR_LABELS" >> $GITHUB_OUTPUT
{
echo "stale-issue-message<<EOF"
echo "$STALE_ISSUE_MSG"
echo "EOF"
echo "close-issue-message<<EOF"
echo "$CLOSE_ISSUE_MSG"
echo "EOF"
echo "stale-pr-message<<EOF"
echo "$STALE_PR_MSG"
echo "EOF"
echo "close-pr-message<<EOF"
echo "$CLOSE_PR_MSG"
echo "EOF"
} >> $GITHUB_OUTPUT
- uses: actions/stale@v9
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: ${{ steps.messages.outputs.stale-issue-message }}
close-issue-message: ${{ steps.messages.outputs.close-issue-message }}
stale-pr-message: ${{ steps.messages.outputs.stale-pr-message }}
close-pr-message: ${{ steps.messages.outputs.close-pr-message }}
days-before-issue-stale: 30
days-before-pr-stale: 45
days-before-issue-close: 5
days-before-pr-close: 10
stale-issue-label: 'stale'
stale-pr-label: 'stale'
exempt-pr-labels: ${{ steps.messages.outputs.exempt-pr-labels }}
enable-statistics: true