Generate man pages workflow (FiloSottile/age)
The Generate man pages workflow from FiloSottile/age, explained and optimized by Latchkey.
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.
What it does
This is the Generate man pages workflow from the FiloSottile/age repository, a real project running GitHub Actions. It is shown here with attribution under its BSD-3-Clause license.
Below, Latchkey shows a faster, safer version produced by its optimization engine.
The workflow
name: Generate man pages
on:
push:
branches:
- '**'
paths:
- '**.ronn'
- '**/ronn.yml'
permissions:
contents: read
jobs:
ronn:
name: Ronn
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
persist-credentials: false
- uses: geomys/sandboxed-step@v1.2.1
with:
persist-workspace-changes: true
run: |
sudo apt-get update && sudo apt-get install -y ronn
bash -O globstar -c 'ronn **/*.ronn'
# rdiscount randomizes the output for no good reason, which causes
# changes to always get committed. Sigh.
# https://github.com/davidfstr/rdiscount/blob/6b1471ec3/ext/generate.c#L781-L795
for f in doc/*.html; do
awk '/Filippo Valsorda/ { $0 = "<p>Filippo Valsorda <a href=\"mailto:age@filippo.io\" data-bare-link=\"true\">age@filippo.io</a></p>" } { print }' "$f" > "$f.tmp"
mv "$f.tmp" "$f"
done
- uses: actions/upload-artifact@v4
with:
name: man-pages
path: |
doc/*.1
doc/*.html
commit:
name: Commit changes
needs: ronn
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
persist-credentials: true
- uses: actions/download-artifact@v4
with:
name: man-pages
path: doc/
- name: Commit and push if changed
run: |-
git config user.name "GitHub Actions"
git config user.email "actions@users.noreply.github.com"
git add doc/
git commit -m "doc: regenerate groff and html man pages" || exit 0
git push
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: Generate man pages on: push: branches: - '**' paths: - '**.ronn' - '**/ronn.yml' permissions: contents: read concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: ronn: timeout-minutes: 30 name: Ronn runs-on: latchkey-small steps: - uses: actions/checkout@v5 with: persist-credentials: false - uses: geomys/sandboxed-step@v1.2.1 with: persist-workspace-changes: true run: | sudo apt-get update && sudo apt-get install -y ronn bash -O globstar -c 'ronn **/*.ronn' # rdiscount randomizes the output for no good reason, which causes # changes to always get committed. Sigh. # https://github.com/davidfstr/rdiscount/blob/6b1471ec3/ext/generate.c#L781-L795 for f in doc/*.html; do awk '/Filippo Valsorda/ { $0 = "<p>Filippo Valsorda <a href=\"mailto:age@filippo.io\" data-bare-link=\"true\">age@filippo.io</a></p>" } { print }' "$f" > "$f.tmp" mv "$f.tmp" "$f" done - uses: actions/upload-artifact@v4 with: name: man-pages path: | doc/*.1 doc/*.html commit: timeout-minutes: 30 name: Commit changes needs: ronn permissions: contents: write runs-on: latchkey-small steps: - uses: actions/checkout@v5 with: persist-credentials: true - uses: actions/download-artifact@v4 with: name: man-pages path: doc/ - name: Commit and push if changed run: |- git config user.name "GitHub Actions" git config user.email "actions@users.noreply.github.com" git add doc/ git commit -m "doc: regenerate groff and html man pages" || exit 0 git push
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.
- 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 2 jobs per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.