docspublish workflow (ddev/ddev)
The docspublish workflow from ddev/ddev, explained and optimized by Latchkey.
CI health: F - at risk
Point runs-on at Latchkey and get caching, run de-duplication, job timeouts, SHA-pinned actions, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the docspublish workflow from the ddev/ddev 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: docspublish
on:
push:
branches: [ main, stable ]
workflow_dispatch:
inputs:
debug_enabled:
description: 'Run the build with tmate set "debug_enabled"'
type: boolean
required: false
default: false
permissions:
contents: read
pages: write
id-token: write
jobs:
docs-deploy:
runs-on: ubuntu-latest
steps:
- name: Setup Pages
id: pages
uses: actions/configure-pages@v6
- name: Checkout main branch
uses: actions/checkout@v7
with:
ref: main
path: checkout-main
fetch-depth: 0
- name: Checkout stable branch
id: checkout-stable
continue-on-error: true
uses: actions/checkout@v7
with:
ref: stable
path: checkout-stable
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: 3.x
- name: Setup tmate session
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
uses: mxschmitt/action-tmate@v3
with:
limit-access-to-actor: true
- name: Install dependencies
run: |
pip install -r checkout-main/docs/requirements.txt
if [ -f checkout-stable/docs/requirements.txt ]; then
pip install -r checkout-stable/docs/requirements.txt
fi
- name: Build latest docs
working-directory: checkout-main
run: |
if [ "${{ steps.checkout-stable.outcome }}" = "success" ]; then
site_url="${{ steps.pages.outputs.base_url }}/en/latest/"
else
site_url="${{ steps.pages.outputs.base_url }}/"
fi
sed -i "s|site_url:.*|site_url: ${site_url}|" mkdocs.yml
grep site_url mkdocs.yml
if [ "${{ steps.checkout-stable.outcome }}" = "success" ]; then
READTHEDOCS_VERSION_NAME=latest zensical build --clean --strict
else
zensical build --clean --strict
fi
- name: Build stable docs
if: steps.checkout-stable.outcome == 'success'
working-directory: checkout-stable
run: |
sed -i "s|site_url:.*|site_url: ${{ steps.pages.outputs.base_url }}/en/stable/|" mkdocs.yml
grep site_url mkdocs.yml
zensical build --clean --strict
- name: Assemble combined site
run: |
if [ -d checkout-stable/site ]; then
mkdir -p combined-site/en
mv -v checkout-main/site combined-site/en/latest
mv -v checkout-stable/site combined-site/en/stable
cp -v combined-site/en/stable/404.html combined-site/404.html
cat > combined-site/index.html <<'EOF'
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="refresh" content="0; url=en/stable/">
<link rel="canonical" href="en/stable/">
</head>
<body>
<a href="en/stable/">Redirecting to stable docs...</a>
</body>
</html>
EOF
else
mv -v checkout-main/site combined-site
fi
- name: Upload pages artifact
uses: actions/upload-pages-artifact@v5
with:
path: combined-site
- name: Deploy to GitHub Pages
uses: actions/deploy-pages@v5
id: deployment
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: docspublish on: push: branches: [ main, stable ] workflow_dispatch: inputs: debug_enabled: description: 'Run the build with tmate set "debug_enabled"' type: boolean required: false default: false permissions: contents: read pages: write id-token: write concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: docs-deploy: timeout-minutes: 30 runs-on: latchkey-small steps: - name: Setup Pages id: pages uses: actions/configure-pages@v6 - name: Checkout main branch uses: actions/checkout@v7 with: ref: main path: checkout-main fetch-depth: 0 - name: Checkout stable branch id: checkout-stable continue-on-error: true uses: actions/checkout@v7 with: ref: stable path: checkout-stable fetch-depth: 0 - name: Set up Python uses: actions/setup-python@v6 with: cache: 'pip' python-version: 3.x - name: Setup tmate session if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }} uses: mxschmitt/action-tmate@v3 with: limit-access-to-actor: true - name: Install dependencies run: | pip install -r checkout-main/docs/requirements.txt if [ -f checkout-stable/docs/requirements.txt ]; then pip install -r checkout-stable/docs/requirements.txt fi - name: Build latest docs working-directory: checkout-main run: | if [ "${{ steps.checkout-stable.outcome }}" = "success" ]; then site_url="${{ steps.pages.outputs.base_url }}/en/latest/" else site_url="${{ steps.pages.outputs.base_url }}/" fi sed -i "s|site_url:.*|site_url: ${site_url}|" mkdocs.yml grep site_url mkdocs.yml if [ "${{ steps.checkout-stable.outcome }}" = "success" ]; then READTHEDOCS_VERSION_NAME=latest zensical build --clean --strict else zensical build --clean --strict fi - name: Build stable docs if: steps.checkout-stable.outcome == 'success' working-directory: checkout-stable run: | sed -i "s|site_url:.*|site_url: ${{ steps.pages.outputs.base_url }}/en/stable/|" mkdocs.yml grep site_url mkdocs.yml zensical build --clean --strict - name: Assemble combined site run: | if [ -d checkout-stable/site ]; then mkdir -p combined-site/en mv -v checkout-main/site combined-site/en/latest mv -v checkout-stable/site combined-site/en/stable cp -v combined-site/en/stable/404.html combined-site/404.html cat > combined-site/index.html <<'EOF' <!DOCTYPE html> <html> <head> <meta http-equiv="refresh" content="0; url=en/stable/"> <link rel="canonical" href="en/stable/"> </head> <body> <a href="en/stable/">Redirecting to stable docs...</a> </body> </html> EOF else mv -v checkout-main/site combined-site fi - name: Upload pages artifact uses: actions/upload-pages-artifact@v5 with: path: combined-site - name: Deploy to GitHub Pages uses: actions/deploy-pages@v5 id: deployment
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.
- Cache dependency installs on the setup step so they are served from cache.
- Add a job timeout so a hung step cannot burn hours of runner time.
1 third-party action is referenced by a movable tag. Pin it 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:
- Dependency installs
This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.