CI workflow (mdo/github-buttons)
The CI workflow from mdo/github-buttons, explained and optimized by Latchkey.
CI health: C - fair
Point runs-on at Latchkey and get run de-duplication, job timeouts, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the CI workflow from the mdo/github-buttons 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
name: CI
on:
push:
branches-ignore:
- "dependabot/**"
tags:
- "*"
pull_request:
workflow_dispatch:
env:
FORCE_COLOR: 2
NODE: 24
RUBY: "3.4"
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Clone repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Set up Node.js
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: ${{ env.NODE }}
cache: npm
- name: Set up Ruby
uses: ruby/setup-ruby@7372622e62b60b3cb750dcd2b9e32c247ffec26a # v1.302.0
with:
ruby-version: ${{ env.RUBY }}
bundler-cache: true
- name: Install npm dependencies
run: npm ci
- name: Run tests
run: npm test
- name: Upload docs
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
if: github.repository == 'mdo/github-buttons' && startsWith(github.ref, 'refs/tags/')
with:
name: docs
path: ./_site/
if-no-files-found: error
deploy:
runs-on: ubuntu-latest
needs: test
if: github.repository == 'mdo/github-buttons' && startsWith(github.ref, 'refs/tags/')
steps:
- name: Clone repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Download docs
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: docs
path: ./_site/
- name: Deploy
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0
with:
allow_empty_commit: false
personal_token: ${{ secrets.PERSONAL_TOKEN }}
publish_branch: gh-pages
publish_dir: ./_site/
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: CI on: push: branches-ignore: - "dependabot/**" tags: - "*" pull_request: workflow_dispatch: env: FORCE_COLOR: 2 NODE: 24 RUBY: "3.4" concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: test: timeout-minutes: 30 runs-on: latchkey-small steps: - name: Clone repository uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: persist-credentials: false - name: Set up Node.js uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0 with: node-version: ${{ env.NODE }} cache: npm - name: Set up Ruby uses: ruby/setup-ruby@7372622e62b60b3cb750dcd2b9e32c247ffec26a # v1.302.0 with: ruby-version: ${{ env.RUBY }} bundler-cache: true - name: Install npm dependencies run: npm ci - name: Run tests run: npm test - name: Upload docs uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 if: github.repository == 'mdo/github-buttons' && startsWith(github.ref, 'refs/tags/') with: name: docs path: ./_site/ if-no-files-found: error deploy: timeout-minutes: 30 runs-on: latchkey-small needs: test if: github.repository == 'mdo/github-buttons' && startsWith(github.ref, 'refs/tags/') steps: - name: Clone repository uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: persist-credentials: false - name: Download docs uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 with: name: docs path: ./_site/ - name: Deploy uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0 with: allow_empty_commit: false personal_token: ${{ secrets.PERSONAL_TOKEN }} publish_branch: gh-pages publish_dir: ./_site/
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. - Cancel superseded runs when a branch or PR gets a newer push.
- Add a job timeout so a hung step cannot burn hours of runner time.
What Latchkey heals here
This workflow has steps that commonly fail on transient issues (network, registries, flaky browsers). On Latchkey managed runners they are detected, retried, and self-healed instead of failing your build:
- Dependency installs
This workflow runs 2 jobs per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.