Skip to content
Latchkey

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.

Grade your own workflow free or run it on Latchkey →
Source: primer/octicons.github/workflows/add-to-inbox.ymlLicense MITView source

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

This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.

Actions used in this workflow