Skip to content
Latchkey

Documentation Preview workflow (python-poetry/poetry)

The Documentation Preview workflow from python-poetry/poetry, 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: python-poetry/poetry.github/workflows/docs.yamlLicense MITView source

What it does

This is the Documentation Preview workflow from the python-poetry/poetry 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: Documentation Preview

on:
  pull_request:
    # allow repository maintainers to modify and test workflow
    paths:
      - ".github/workflows/docs.yaml"
  pull_request_target:  # zizmor: ignore[dangerous-triggers]
    # enable runs for this workflow when labeled as documentation only
    # prevent execution when the workflow itself is modified from a fork
    types:
      - labeled
      - synchronize
    paths:
      - "docs/**"

jobs:
  deploy:
    name: Build & Deploy
    runs-on: ubuntu-latest
    if: >
      (github.event_name == 'pull_request_target' && contains(github.event.pull_request.labels.*.name, 'impact/docs'))
      || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository)
    permissions:
      contents: read
      pull-requests: write
    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
        with:
          persist-credentials: false
          repository: python-poetry/website

      # use .github from pull request target instead of pull_request.head
      # for pull_request_target trigger to avoid arbitrary code execution
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
        with:
          persist-credentials: false
          path: poetry-github
          sparse-checkout: .github

      # only checkout docs from pull_request.head to not use something else by accident
      # for pull_request_target trigger (security)
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
        with:
          persist-credentials: false
          path: poetry-docs
          ref: ${{ github.event.pull_request.head.sha }}
          sparse-checkout: docs

      - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
        with:
          node-version: "22"

      - uses: ./poetry-github/.github/actions/bootstrap-poetry

      - uses: ./poetry-github/.github/actions/poetry-install
        with:
          args: --no-root --only main

      - name: website-build
        run: |
          # Rebuild the docs files from the PR checkout.
          poetry run python bin/website build --local ./poetry-docs
          # Build website assets (CSS/JS).
          npm ci && npm run prod
          # Build the static website.
          npx hugo --minify --logLevel info

      - uses: amondnet/vercel-action@de09aeac2ace6599ec9b11ef87558759a496bac4 # v42.3.0
        with:
          vercel-version: 50.44.0
          vercel-token: ${{ secrets.VERCEL_TOKEN }}
          github-token: ${{ secrets.GITHUB_TOKEN }}
          vercel-org-id: ${{ secrets.VERCEL_ORG_ID }}
          vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }}
          scope: python-poetry
          github-comment: true
          working-directory: public

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: Documentation Preview
 
on:
  pull_request:
    # allow repository maintainers to modify and test workflow
    paths:
      - ".github/workflows/docs.yaml"
  pull_request_target:  # zizmor: ignore[dangerous-triggers]
    # enable runs for this workflow when labeled as documentation only
    # prevent execution when the workflow itself is modified from a fork
    types:
      - labeled
      - synchronize
    paths:
      - "docs/**"
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  deploy:
    timeout-minutes: 30
    name: Build & Deploy
    runs-on: latchkey-small
    if: >
      (github.event_name == 'pull_request_target' && contains(github.event.pull_request.labels.*.name, 'impact/docs'))
      || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository)
    permissions:
      contents: read
      pull-requests: write
    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
        with:
          persist-credentials: false
          repository: python-poetry/website
 
      # use .github from pull request target instead of pull_request.head
      # for pull_request_target trigger to avoid arbitrary code execution
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
        with:
          persist-credentials: false
          path: poetry-github
          sparse-checkout: .github
 
      # only checkout docs from pull_request.head to not use something else by accident
      # for pull_request_target trigger (security)
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
        with:
          persist-credentials: false
          path: poetry-docs
          ref: ${{ github.event.pull_request.head.sha }}
          sparse-checkout: docs
 
      - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
        with:
          cache: 'npm'
          node-version: "22"
 
      - uses: ./poetry-github/.github/actions/bootstrap-poetry
 
      - uses: ./poetry-github/.github/actions/poetry-install
        with:
          args: --no-root --only main
 
      - name: website-build
        run: |
          # Rebuild the docs files from the PR checkout.
          poetry run python bin/website build --local ./poetry-docs
          # Build website assets (CSS/JS).
          npm ci && npm run prod
          # Build the static website.
          npx hugo --minify --logLevel info
 
      - uses: amondnet/vercel-action@de09aeac2ace6599ec9b11ef87558759a496bac4 # v42.3.0
        with:
          vercel-version: 50.44.0
          vercel-token: ${{ secrets.VERCEL_TOKEN }}
          github-token: ${{ secrets.GITHUB_TOKEN }}
          vercel-org-id: ${{ secrets.VERCEL_ORG_ID }}
          vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }}
          scope: python-poetry
          github-comment: true
          working-directory: public
 

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