Close stale issues and PRs workflow (js-cookie/js-cookie)
The Close stale issues and PRs workflow from js-cookie/js-cookie, explained and optimized by Latchkey.
A
CI health: A - excellent
Point runs-on at Latchkey and get job timeouts, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the Close stale issues and PRs workflow from the js-cookie/js-cookie repository, a real project running GitHub Actions. It is shown here with attribution under its MIT license.
Below, Latchkey shows a faster, safer version produced by its optimization engine.
The workflow
workflow (.yml)
name: Close stale issues and PRs
on:
schedule:
- cron: '0 8 * * 0'
workflow_dispatch:
permissions: {}
jobs:
stale:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- name: Close stale issues/pull requests
uses: actions/stale@eb5cf3af3ac0a1aa4c9c45633dd1ae542a27a899 # v10.3.0
with:
stale-issue-message: 'This issue has been marked as stale because it has been open for 90 days with no activity. This thread will be automatically closed in 30 days if no further activity occurs.'
stale-pr-message: 'This pull request has been marked as stale because it has been open for 90 days with no activity. This thread will be automatically closed in 30 days if no further activity occurs.'
exempt-issue-labels: 'feature request,in progress,dependencies'
days-before-stale: 90
days-before-close: 30
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: Close stale issues and PRs on: schedule: - cron: '0 8 * * 0' workflow_dispatch: permissions: {} jobs: stale: timeout-minutes: 30 runs-on: latchkey-small permissions: issues: write pull-requests: write steps: - name: Close stale issues/pull requests uses: actions/stale@eb5cf3af3ac0a1aa4c9c45633dd1ae542a27a899 # v10.3.0 with: stale-issue-message: 'This issue has been marked as stale because it has been open for 90 days with no activity. This thread will be automatically closed in 30 days if no further activity occurs.' stale-pr-message: 'This pull request has been marked as stale because it has been open for 90 days with no activity. This thread will be automatically closed in 30 days if no further activity occurs.' exempt-issue-labels: 'feature request,in progress,dependencies' days-before-stale: 90 days-before-close: 30
What changed
- Run on Latchkey managed runners with one line (
runs-on), which apply the fixes below automatically and self-heal transient failures. This example useslatchkey-small; pick the runner size that fits the job. - Add a job timeout so a hung step cannot burn hours of runner time.
This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.