Skip to content
Latchkey

documentation workflow (apache/burr)

The documentation workflow from apache/burr, 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: apache/burr.github/workflows/docs.ymlLicense Apache-2.0View source

What it does

This is the documentation workflow from the apache/burr 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)
#<!--
#     Licensed to the Apache Software Foundation (ASF) under one
#     or more contributor license agreements.  See the NOTICE file
#     distributed with this work for additional information
#     regarding copyright ownership.  The ASF licenses this file
#     to you under the Apache License, Version 2.0 (the
#     "License"); you may not use this file except in compliance
#     with the License.  You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
#     Unless required by applicable law or agreed to in writing,
#     software distributed under the License is distributed on an
#     "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
#     KIND, either express or implied.  See the License for the
#     specific language governing permissions and limitations
#     under the License.
#-->
name: documentation

on:
  push:
    branches:
      - main # Triggers the workflow on push events to the main branch
  pull_request:
    # Triggers the workflow on pull request events for any branch
    types: [opened, synchronize, reopened]

permissions:
  contents: write

concurrency: ci-${{ github.ref }}

jobs:
  docs:
    runs-on: ubuntu-latest
    env:
      PR_PATH: pull/${{github.event.number}}
      BASE_URL: https://burr.apache.org/pull/${{github.event.number}}
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v4
        with:
          python-version: '3.12'
      - name: Install dependencies
        run: |
          pip install -e ".[documentation]"
      - name: Sphinx build
        run: |
          sphinx-build docs -b dirhtml _build
          echo "burr.apache.org" > _build/CNAME # keep the cname file which this clobbers -- todo, unhardcode
      - name: Comment on PR
        uses: hasura/comment-progress@v2.2.0
        if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          repository: ${{ github.repository }}
          number: ${{ github.event.number }}
          id: deploy-preview
          message: "Starting deployment of preview ⏳..."
      - name: Build PR preview website
        uses: peaceiris/actions-gh-pages@v3
        if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_dir: _build/
          destination_dir: ${{ env.PR_PATH }} # TODO you need to set this if you're using a custom domain. Otherwise you can remove it.
      - name: Deploy to GitHub Pages
        uses: peaceiris/actions-gh-pages@v3
        if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
        with:
          publish_branch: gh-pages
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_dir: _build/
          keep_files: true # Add this line to keep existing files in the gh-pages branch
      - name: Update comment
        uses: hasura/comment-progress@v2.2.0
        if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          repository: ${{ github.repository }}
          number: ${{ github.event.number }}
          id: deploy-preview
          message: "A preview of ${{ github.event.after }} is uploaded and can be seen here:\n\n ✨ ${{ env.BASE_URL }} ✨\n\nChanges may take a few minutes to propagate. Since this is a preview of production, content with `draft: true` will not be rendered. The source is here: https://github.com/${{ github.repository }}/tree/gh-pages/${{ env.PR_PATH }}/"

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.

#<!--
#     Licensed to the Apache Software Foundation (ASF) under one
#     or more contributor license agreements.  See the NOTICE file
#     distributed with this work for additional information
#     regarding copyright ownership.  The ASF licenses this file
#     to you under the Apache License, Version 2.0 (the
#     "License"); you may not use this file except in compliance
#     with the License.  You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
#     Unless required by applicable law or agreed to in writing,
#     software distributed under the License is distributed on an
#     "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
#     KIND, either express or implied.  See the License for the
#     specific language governing permissions and limitations
#     under the License.
#-->
name: documentation
 
on:
  push:
    branches:
      - main # Triggers the workflow on push events to the main branch
  pull_request:
    # Triggers the workflow on pull request events for any branch
    types: [opened, synchronize, reopened]
 
permissions:
  contents: write
 
concurrency: ci-${{ github.ref }}
 
jobs:
  docs:
    timeout-minutes: 30
    runs-on: latchkey-small
    env:
      PR_PATH: pull/${{github.event.number}}
      BASE_URL: https://burr.apache.org/pull/${{github.event.number}}
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v4
        with:
          cache: 'pip'
          python-version: '3.12'
      - name: Install dependencies
        run: |
          pip install -e ".[documentation]"
      - name: Sphinx build
        run: |
          sphinx-build docs -b dirhtml _build
          echo "burr.apache.org" > _build/CNAME # keep the cname file which this clobbers -- todo, unhardcode
      - name: Comment on PR
        uses: hasura/comment-progress@v2.2.0
        if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          repository: ${{ github.repository }}
          number: ${{ github.event.number }}
          id: deploy-preview
          message: "Starting deployment of preview ⏳..."
      - name: Build PR preview website
        uses: peaceiris/actions-gh-pages@v3
        if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_dir: _build/
          destination_dir: ${{ env.PR_PATH }} # TODO you need to set this if you're using a custom domain. Otherwise you can remove it.
      - name: Deploy to GitHub Pages
        uses: peaceiris/actions-gh-pages@v3
        if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
        with:
          publish_branch: gh-pages
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_dir: _build/
          keep_files: true # Add this line to keep existing files in the gh-pages branch
      - name: Update comment
        uses: hasura/comment-progress@v2.2.0
        if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          repository: ${{ github.repository }}
          number: ${{ github.event.number }}
          id: deploy-preview
          message: "A preview of ${{ github.event.after }} is uploaded and can be seen here:\n\n ✨ ${{ env.BASE_URL }} ✨\n\nChanges may take a few minutes to propagate. Since this is a preview of production, content with `draft: true` will not be rendered. The source is here: https://github.com/${{ github.repository }}/tree/gh-pages/${{ env.PR_PATH }}/"
 

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