|
| 1 | +name: 'stale' |
| 2 | +on: |
| 3 | + schedule: |
| 4 | + - cron: '42 0 * * *' |
| 5 | + |
| 6 | + workflow_dispatch: |
| 7 | + # Manual triggering through the GitHub UI, API, or CLI |
| 8 | + inputs: |
| 9 | + daysBeforeStale: |
| 10 | + required: true |
| 11 | + default: "180" |
| 12 | + daysBeforeClose: |
| 13 | + required: true |
| 14 | + default: "30" |
| 15 | + operationsPerRun: |
| 16 | + required: true |
| 17 | + default: "4000" |
| 18 | + |
| 19 | +permissions: |
| 20 | + actions: write # For managing the operation state cache |
| 21 | + issues: write |
| 22 | + |
| 23 | +jobs: |
| 24 | + stale: |
| 25 | + # Do not run on forks |
| 26 | + if: github.repository_owner == 'devlooped' |
| 27 | + runs-on: ubuntu-latest |
| 28 | + steps: |
| 29 | + - name: ⌛ rate |
| 30 | + shell: pwsh |
| 31 | + if: github.event_name != 'workflow_dispatch' |
| 32 | + env: |
| 33 | + GH_TOKEN: ${{ github.token }} |
| 34 | + run: | |
| 35 | + # add random sleep since we run on fixed schedule |
| 36 | + $wait = get-random -max 180 |
| 37 | + echo "Waiting random $wait seconds to start" |
| 38 | + sleep $wait |
| 39 | + # get currently authenticated user rate limit info |
| 40 | + $rate = gh api rate_limit | convertfrom-json | select -expandproperty rate |
| 41 | + # if we don't have at least 100 requests left, wait until reset |
| 42 | + if ($rate.remaining -lt 100) { |
| 43 | + $wait = ($rate.reset - (Get-Date (Get-Date).ToUniversalTime() -UFormat %s)) |
| 44 | + echo "Rate limit remaining is $($rate.remaining), waiting for $($wait / 1000) seconds to reset" |
| 45 | + sleep $wait |
| 46 | + $rate = gh api rate_limit | convertfrom-json | select -expandproperty rate |
| 47 | + echo "Rate limit has reset to $($rate.remaining) requests" |
| 48 | + } |
| 49 | + |
| 50 | + - name: ✏️ label |
| 51 | + # pending merge: https://github.com/actions/stale/pull/1176 |
| 52 | + uses: kzu/stale@c8450312ba97b204bf37545cb249742144d6ca69 |
| 53 | + with: |
| 54 | + ascending: true # Process the oldest issues first |
| 55 | + stale-issue-label: 'stale' |
| 56 | + stale-issue-message: | |
| 57 | + Due to lack of recent activity, this issue has been labeled as 'stale'. |
| 58 | + It will be closed if no further activity occurs within ${{ fromJson(inputs.daysBeforeClose || 30 ) }} more days. |
| 59 | + Any new comment will remove the label. |
| 60 | + close-issue-message: | |
| 61 | + This issue will now be closed since it has been labeled 'stale' without activity for ${{ fromJson(inputs.daysBeforeClose || 30 ) }} days. |
| 62 | + days-before-stale: ${{ fromJson(inputs.daysBeforeStale || 180) }} |
| 63 | + days-before-close: ${{ fromJson(inputs.daysBeforeClose || 30 ) }} |
| 64 | + days-before-pr-close: -1 # Do not close PRs labeled as 'stale' |
| 65 | + operations-per-run: ${{ fromJson(inputs.operationsPerRun || 4000 )}} |
| 66 | + exempt-all-milestones: true |
| 67 | + exempt-all-assignees: true |
| 68 | + exempt-issue-labels: priority,sponsor,backed |
| 69 | + exempt-authors: kzu |
0 commit comments