Skip to content
Latchkey

build docs workflow (gdsfactory/gdsfactory)

The build docs workflow from gdsfactory/gdsfactory, explained and optimized by Latchkey.

C

CI health: C - fair

Point runs-on at Latchkey and get caching, job timeouts, SHA-pinned actions, self-healing for flaky steps, and up to 58% lower cost, applied automatically.

Grade your own workflow free or run it on Latchkey →
Source: gdsfactory/gdsfactory.github/workflows/pages.ymlLicense MITView source

What it does

This is the build docs workflow from the gdsfactory/gdsfactory 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: build docs
on:
  pull_request:
  push:
    branches:
      - main
  workflow_dispatch:
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
jobs:
  build-docs:
    runs-on: ubuntu-latest
    name: Sphinx docs to gh-pages
    permissions:
      contents: read
    steps:
      - name: Cancel Workflow Action
        uses: styfle/cancel-workflow-action@0.13.1
      - uses: actions/checkout@v7.0.0
      - uses: actions/cache@v6.1.0
        with:
          path: |
            ~/.gdsfactory/
          key: 0.0.1
          restore-keys: 0.0.1
      - name: Set up Python 3.11
        uses: actions/setup-python@v6
        with:
          python-version: '3.11'
      - name: Install uv
        uses: astral-sh/setup-uv@v7
      - name: Installing the library
        run: |
          make install
          sudo apt install graphviz graphviz-dev -y
      - name: Build the docs
        env:
          GDSFACTORY_DISPLAY_TYPE: klayout
          KFACTORY_DISPLAY_TYPE: image
        run: |
          make docs
      - name: Upload artifact
        uses: actions/upload-pages-artifact@v5
        with:
          path: "./docs/_build/html/"
          retention-days: 7
  deploy-docs:
    needs: build-docs
    if: ${{ github.ref == 'refs/heads/main' }}
    permissions:
      pages: write
      id-token: write
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    runs-on: ubuntu-latest
    steps:
      - name: Deploy to GitHub Pages
        id: deployment
        uses: actions/deploy-pages@v5

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: build docs
on:
  pull_request:
  push:
    branches:
      - main
  workflow_dispatch:
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
jobs:
  build-docs:
    timeout-minutes: 30
    runs-on: latchkey-small
    name: Sphinx docs to gh-pages
    permissions:
      contents: read
    steps:
      - name: Cancel Workflow Action
        uses: styfle/cancel-workflow-action@0.13.1
      - uses: actions/checkout@v7.0.0
      - uses: actions/cache@v6.1.0
        with:
          path: |
            ~/.gdsfactory/
          key: 0.0.1
          restore-keys: 0.0.1
      - name: Set up Python 3.11
        uses: actions/setup-python@v6
        with:
          cache: 'pip'
          python-version: '3.11'
      - name: Install uv
        uses: astral-sh/setup-uv@v7
      - name: Installing the library
        run: |
          make install
          sudo apt install graphviz graphviz-dev -y
      - name: Build the docs
        env:
          GDSFACTORY_DISPLAY_TYPE: klayout
          KFACTORY_DISPLAY_TYPE: image
        run: |
          make docs
      - name: Upload artifact
        uses: actions/upload-pages-artifact@v5
        with:
          path: "./docs/_build/html/"
          retention-days: 7
  deploy-docs:
    timeout-minutes: 30
    needs: build-docs
    if: ${{ github.ref == 'refs/heads/main' }}
    permissions:
      pages: write
      id-token: write
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    runs-on: latchkey-small
    steps:
      - name: Deploy to GitHub Pages
        id: deployment
        uses: actions/deploy-pages@v5
 

What changed

2 third-party actions are referenced by a movable tag. Pin them to the commit SHA (Latchkey resolves and applies this automatically) so a repointed tag cannot change what runs.

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 2 jobs per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.

Actions used in this workflow