Autoclose Issues workflow (psf/requests)
The Autoclose Issues workflow from psf/requests, 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 Autoclose Issues workflow from the psf/requests repository, a real project running GitHub Actions. It is shown here with attribution under its Apache-2.0 license.
Below, Latchkey shows a faster, safer version produced by its optimization engine.
The workflow
workflow (.yml)
name: 'Autoclose Issues'
on:
issues:
types:
- labeled
permissions: {}
jobs:
close_qa:
permissions:
issues: write
if: github.event.label.name == 'actions/autoclose-qa'
runs-on: ubuntu-latest
steps:
- env:
ISSUE_URL: ${{ github.event.issue.html_url }}
GH_TOKEN: ${{ github.token }}
run: |
gh issue close $ISSUE_URL \
--comment "As described in the template, we won't be able to answer questions on this issue tracker. Please use [Stack Overflow](https://stackoverflow.com/)" \
--reason completed
gh issue lock $ISSUE_URL --reason off_topic
close_feature_request:
permissions:
issues: write
if: github.event.label.name == 'actions/autoclose-feat'
runs-on: ubuntu-latest
steps:
- env:
ISSUE_URL: ${{ github.event.issue.html_url }}
GH_TOKEN: ${{ github.token }}
run: |
gh issue close $ISSUE_URL \
--comment "As described in the template, Requests is not accepting feature requests" \
--reason "not planned"
gh issue lock $ISSUE_URL --reason off_topic
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: 'Autoclose Issues' on: issues: types: - labeled permissions: {} jobs: close_qa: timeout-minutes: 30 permissions: issues: write if: github.event.label.name == 'actions/autoclose-qa' runs-on: latchkey-small steps: - env: ISSUE_URL: ${{ github.event.issue.html_url }} GH_TOKEN: ${{ github.token }} run: | gh issue close $ISSUE_URL \ --comment "As described in the template, we won't be able to answer questions on this issue tracker. Please use [Stack Overflow](https://stackoverflow.com/)" \ --reason completed gh issue lock $ISSUE_URL --reason off_topic close_feature_request: timeout-minutes: 30 permissions: issues: write if: github.event.label.name == 'actions/autoclose-feat' runs-on: latchkey-small steps: - env: ISSUE_URL: ${{ github.event.issue.html_url }} GH_TOKEN: ${{ github.token }} run: | gh issue close $ISSUE_URL \ --comment "As described in the template, Requests is not accepting feature requests" \ --reason "not planned" gh issue lock $ISSUE_URL --reason off_topic
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 2 jobs per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.