Add to Inbox π₯ workflow (primer/octicons)
The Add to Inbox π₯ workflow from primer/octicons, 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 Add to Inbox π₯ workflow from the primer/octicons 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: Add to Inbox π₯
on:
issues:
types: [opened, reopened]
jobs:
add-to-inbox:
if: ${{ github.repository == 'primer/behaviors' }}
runs-on: ubuntu-latest
env:
ISSUE_URL: ${{ github.event.issue.html_url }}
PROJECT_ID: 4503
steps:
- id: get-primer-access-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ vars.PRIMER_ISSUE_TRIAGE_APP_ID }}
private-key: ${{ secrets.PRIMER_ISSUE_TRIAGE_APP_PRIVATE_KEY }}
- name: Add labels to issue
run: |
gh issue edit $ISSUE_URL --add-label 'rails,react'
env:
GH_TOKEN: ${{ steps.get-primer-access-token.outputs.token }}
- id: get-github-access-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ vars.PRIMER_ISSUE_TRIAGE_APP_ID_FOR_GITHUB }}
private-key: ${{ secrets.PRIMER_ISSUE_TRIAGE_APP_PRIVATE_KEY_FOR_GITHUB }}
owner: github
- name: Add issue to project
run: gh project item-add $PROJECT_ID --url $ISSUE_URL --owner github
env:
GH_TOKEN: ${{ steps.get-github-access-token.outputs.token }}
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: Add to Inbox π₯ on: issues: types: [opened, reopened] jobs: add-to-inbox: timeout-minutes: 30 if: ${{ github.repository == 'primer/behaviors' }} runs-on: latchkey-small env: ISSUE_URL: ${{ github.event.issue.html_url }} PROJECT_ID: 4503 steps: - id: get-primer-access-token uses: actions/create-github-app-token@v1 with: app-id: ${{ vars.PRIMER_ISSUE_TRIAGE_APP_ID }} private-key: ${{ secrets.PRIMER_ISSUE_TRIAGE_APP_PRIVATE_KEY }} - name: Add labels to issue run: | gh issue edit $ISSUE_URL --add-label 'rails,react' env: GH_TOKEN: ${{ steps.get-primer-access-token.outputs.token }} - id: get-github-access-token uses: actions/create-github-app-token@v1 with: app-id: ${{ vars.PRIMER_ISSUE_TRIAGE_APP_ID_FOR_GITHUB }} private-key: ${{ secrets.PRIMER_ISSUE_TRIAGE_APP_PRIVATE_KEY_FOR_GITHUB }} owner: github - name: Add issue to project run: gh project item-add $PROJECT_ID --url $ISSUE_URL --owner github env: GH_TOKEN: ${{ steps.get-github-access-token.outputs.token }}
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.