Skip to content
Latchkey

Publish docs via GitHub Pages workflow (developmentseed/lonboard)

The Publish docs via GitHub Pages workflow from developmentseed/lonboard, explained and optimized by Latchkey.

C

CI health: C - fair

Point runs-on at Latchkey and get run de-duplication, 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: developmentseed/lonboard.github/workflows/deploy-mkdocs.ymlLicense MITView source

What it does

This is the Publish docs via GitHub Pages workflow from the developmentseed/lonboard 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: Publish docs via GitHub Pages

# Only run on new tags starting with `v`
on:
  push:
    tags:
      - "v*"
  workflow_dispatch:

jobs:
  build:
    name: Deploy docs
    runs-on: ubuntu-latest
    steps:
      - uses: actions/create-github-app-token@v3.2.0
        id: app-token
        with:
          app-id: ${{ secrets.DS_RELEASE_BOT_ID }}
          private-key: ${{ secrets.DS_RELEASE_BOT_PRIVATE_KEY }}
          permission-contents: write

      - uses: actions/checkout@v7
        # We need to additionally fetch the gh-pages branch for mike deploy
        with:
          fetch-depth: 0
          token: ${{ steps.app-token.outputs.token }}

      - name: Install a specific version of uv
        uses: astral-sh/setup-uv@v7
        with:
          enable-cache: true
          version: "0.4.x"

      - name: Deploy docs
        env:
          GIT_COMMITTER_NAME: CI
          GIT_COMMITTER_EMAIL: ci-bot@example.com
        run: |
          # Get most recent git tag
          # https://stackoverflow.com/a/7261049
          # We don't use {{github.ref_name}} because if triggered manually, it
          # will be a branch name instead of a tag version.
          VERSION=$(git describe --tags --abbrev=0)

          # Only push docs if no letters in git tag after the first character
          # (usually the git tag will have v as the first character)
          if ! echo $VERSION | sed 's/^.//' | grep -q "[A-Za-z]"; then
            uv run --group docs mike deploy $VERSION latest --update-aliases --push
          fi

The same workflow, on Latchkey

Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.

name: Publish docs via GitHub Pages
 
# Only run on new tags starting with `v`
on:
  push:
    tags:
      - "v*"
  workflow_dispatch:
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  build:
    timeout-minutes: 30
    name: Deploy docs
    runs-on: latchkey-small
    steps:
      - uses: actions/create-github-app-token@v3.2.0
        id: app-token
        with:
          app-id: ${{ secrets.DS_RELEASE_BOT_ID }}
          private-key: ${{ secrets.DS_RELEASE_BOT_PRIVATE_KEY }}
          permission-contents: write
 
      - uses: actions/checkout@v7
        # We need to additionally fetch the gh-pages branch for mike deploy
        with:
          fetch-depth: 0
          token: ${{ steps.app-token.outputs.token }}
 
      - name: Install a specific version of uv
        uses: astral-sh/setup-uv@v7
        with:
          enable-cache: true
          version: "0.4.x"
 
      - name: Deploy docs
        env:
          GIT_COMMITTER_NAME: CI
          GIT_COMMITTER_EMAIL: ci-bot@example.com
        run: |
          # Get most recent git tag
          # https://stackoverflow.com/a/7261049
          # We don't use {{github.ref_name}} because if triggered manually, it
          # will be a branch name instead of a tag version.
          VERSION=$(git describe --tags --abbrev=0)
 
          # Only push docs if no letters in git tag after the first character
          # (usually the git tag will have v as the first character)
          if ! echo $VERSION | sed 's/^.//' | grep -q "[A-Za-z]"; then
            uv run --group docs mike deploy $VERSION latest --update-aliases --push
          fi
 

What changed

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.

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