Skip to content
Latchkey

Docs workflow (microsoft/Olive)

The Docs workflow from microsoft/Olive, explained and optimized by Latchkey.

C

CI health: C - fair

Point runs-on at Latchkey and get caching, 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: microsoft/Olive.github/workflows/docs.ymlLicense MITView source

What it does

This is the Docs workflow from the microsoft/Olive 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: "Docs"
description: "CI workflow to verify docs build"


concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true


on:
  workflow_dispatch:
  push:
    branches:
      - "main"
  pull_request:
    branches:
      - "main"


env:
  PYTHON_VERSION: "3.12"


jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    - name: Checkout Code
      uses: actions/checkout@v4

    - name: Setup python
      uses: actions/setup-python@v5
      with:
        python-version: ${{ env.PYTHON_VERSION }}

    - name: Build docs
      env:
        OLIVE_DOCS_VERSION: main
      run: |
        python -m pip install .
        cd docs
        python -m pip install -r requirements.txt
        python -m pip install onnxruntime torch
        make html
        make linkcheck
        make schema

    - name: Upload built docs
      uses: actions/upload-artifact@v4
      with:
        name: docs-html
        path: docs/build/html
        if-no-files-found: error

  publish:
    if: github.event_name == 'push' && github.ref == 'refs/heads/main'
    needs: build
    runs-on: ubuntu-latest
    permissions:
      contents: write

    steps:
    - name: Checkout Code
      uses: actions/checkout@v4
      with:
        fetch-depth: 0

    - name: Download built docs
      uses: actions/download-artifact@v4
      with:
        name: docs-html
        path: docs-publish

    - name: Publish docs to gh-pages root
      env:
        GH_PAGES_DIR: ../gh-pages-worktree
      run: |
        set -euxo pipefail

        git config user.name "github-actions[bot]"
        git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
        git fetch origin gh-pages
        rm -rf "$GH_PAGES_DIR"
        git worktree add "$GH_PAGES_DIR" origin/gh-pages

        cd "$GH_PAGES_DIR"
        find . -mindepth 1 -maxdepth 1 \
          ! -name '.git' \
          ! -name 'CNAME' \
          ! -name '.nojekyll' \
          ! -name '.gitignore' \
          ! -regex './[0-9]+\.[0-9]+\.[0-9]+' \
          -exec rm -rf {} +

        cp -a "$GITHUB_WORKSPACE/docs-publish/." .
        touch .nojekyll

        git add -A
        if git diff --cached --quiet; then
          echo "No docs changes to publish"
          exit 0
        fi

        git commit -m "Publish docs for ${GITHUB_SHA}"
        git push origin HEAD:gh-pages

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: "Docs"
description: "CI workflow to verify docs build"
 
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
 
on:
  workflow_dispatch:
  push:
    branches:
      - "main"
  pull_request:
    branches:
      - "main"
 
 
env:
  PYTHON_VERSION: "3.12"
 
 
jobs:
  build:
    timeout-minutes: 30
    runs-on: latchkey-small
 
    steps:
    - name: Checkout Code
      uses: actions/checkout@v4
 
    - name: Setup python
      uses: actions/setup-python@v5
      with:
        cache: 'pip'
        python-version: ${{ env.PYTHON_VERSION }}
 
    - name: Build docs
      env:
        OLIVE_DOCS_VERSION: main
      run: |
        python -m pip install .
        cd docs
        python -m pip install -r requirements.txt
        python -m pip install onnxruntime torch
        make html
        make linkcheck
        make schema
 
    - name: Upload built docs
      uses: actions/upload-artifact@v4
      with:
        name: docs-html
        path: docs/build/html
        if-no-files-found: error
 
  publish:
    timeout-minutes: 30
    if: github.event_name == 'push' && github.ref == 'refs/heads/main'
    needs: build
    runs-on: latchkey-small
    permissions:
      contents: write
 
    steps:
    - name: Checkout Code
      uses: actions/checkout@v4
      with:
        fetch-depth: 0
 
    - name: Download built docs
      uses: actions/download-artifact@v4
      with:
        name: docs-html
        path: docs-publish
 
    - name: Publish docs to gh-pages root
      env:
        GH_PAGES_DIR: ../gh-pages-worktree
      run: |
        set -euxo pipefail
 
        git config user.name "github-actions[bot]"
        git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
        git fetch origin gh-pages
        rm -rf "$GH_PAGES_DIR"
        git worktree add "$GH_PAGES_DIR" origin/gh-pages
 
        cd "$GH_PAGES_DIR"
        find . -mindepth 1 -maxdepth 1 \
          ! -name '.git' \
          ! -name 'CNAME' \
          ! -name '.nojekyll' \
          ! -name '.gitignore' \
          ! -regex './[0-9]+\.[0-9]+\.[0-9]+' \
          -exec rm -rf {} +
 
        cp -a "$GITHUB_WORKSPACE/docs-publish/." .
        touch .nojekyll
 
        git add -A
        if git diff --cached --quiet; then
          echo "No docs changes to publish"
          exit 0
        fi
 
        git commit -m "Publish docs for ${GITHUB_SHA}"
        git push origin HEAD:gh-pages
 

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 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