Skip to content
Latchkey

website workflow (bojand/ghz)

The website workflow from bojand/ghz, explained and optimized by Latchkey.

D

CI health: D - needs work

Point runs-on at Latchkey and get caching, run de-duplication, 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: bojand/ghz.github/workflows/website.yamlLicense Apache-2.0View source

What it does

This is the website workflow from the bojand/ghz 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: website

on:
  push:
    branches:
    - master
    paths:
    - 'www/docs/*.md'
    - 'www/docs/web/*.md'
    - 'www/website/*'

jobs:
  build:
    env:
      WWW_TARGET_BRANCH: gh-pages
    runs-on: ubuntu-latest
    steps:
      - name: Check out code
        uses: actions/checkout@v3
      - name: Use Node.js 18
        uses: actions/setup-node@v3
        with:
          node-version: 18.x
      - name: Build webpage
        run: |
          npm ci
          npm run build
        working-directory: ./www/website
      - name: Copy data
        run: |
          mkdir -p ${{env.HOME}}/tmp/www/build
          cp -r ./www/website/build/ghz/. ${{env.HOME}}/tmp/www/build
      - name: Check out target branch
        uses: actions/checkout@v3
        with:
          ref: ${{ env.WWW_TARGET_BRANCH }}
      - name: Copy new data
        run: |
          cp -r ${{env.HOME}}/tmp/www/build/. .
      - name: Commit to repository
        env:
          GITHUB_TOKEN: ${{ secrets.GH_PAGES_ACTION_TOKEN }}
          COMMIT_MSG: Update website
        run: |
          git config user.email "dbojan@gmail.com"
          git config user.name "Bojan"
          # Update origin with token
          git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git
          # Add changed files
          git add .
          # Only commit and push if we have changes
          git diff --quiet && git diff --staged --quiet || (git commit -m "${COMMIT_MSG}"; git push origin ${WWW_TARGET_BRANCH})

The same workflow, on Latchkey

Estimated ~20% faster on cache hits, plus fewer wasted runs and a safer supply chain. Added and changed lines are highlighted.

name: website
 
on:
  push:
    branches:
    - master
    paths:
    - 'www/docs/*.md'
    - 'www/docs/web/*.md'
    - 'www/website/*'
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  build:
    timeout-minutes: 30
    env:
      WWW_TARGET_BRANCH: gh-pages
    runs-on: latchkey-small
    steps:
      - name: Check out code
        uses: actions/checkout@v3
      - name: Use Node.js 18
        uses: actions/setup-node@v3
        with:
          cache: 'npm'
          node-version: 18.x
      - name: Build webpage
        run: |
          npm ci
          npm run build
        working-directory: ./www/website
      - name: Copy data
        run: |
          mkdir -p ${{env.HOME}}/tmp/www/build
          cp -r ./www/website/build/ghz/. ${{env.HOME}}/tmp/www/build
      - name: Check out target branch
        uses: actions/checkout@v3
        with:
          ref: ${{ env.WWW_TARGET_BRANCH }}
      - name: Copy new data
        run: |
          cp -r ${{env.HOME}}/tmp/www/build/. .
      - name: Commit to repository
        env:
          GITHUB_TOKEN: ${{ secrets.GH_PAGES_ACTION_TOKEN }}
          COMMIT_MSG: Update website
        run: |
          git config user.email "dbojan@gmail.com"
          git config user.name "Bojan"
          # Update origin with token
          git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git
          # Add changed files
          git add .
          # Only commit and push if we have changes
          git diff --quiet && git diff --staged --quiet || (git commit -m "${COMMIT_MSG}"; git push origin ${WWW_TARGET_BRANCH})
 

What changed

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:

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