Publish Docsite workflow (containers/ramalama)
The Publish Docsite workflow from containers/ramalama, explained and optimized by Latchkey.
C
CI health: C - fair
Point runs-on at Latchkey and get run de-duplication, job timeouts, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the Publish Docsite workflow from the containers/ramalama 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 Docsite
on:
push:
branches:
- main
paths:
- 'docs/**'
- 'docsite/**'
- '.github/workflows/docsite-publish.yml'
workflow_dispatch:
env:
TARGET_REPO: "containers/ramalama.github.io"
TARGET_BRANCH: "main"
TARGET_DIR: "public/docs"
TARGET_WORKDIR: "ramalama.github.io"
PUBLISH_TOKEN: ${{ secrets.DOCSITE_PUBLISH_TOKEN }}
jobs:
publish:
if: |
github.repository_owner == 'containers'
runs-on: ubuntu-latest
steps:
- name: Checkout RamaLama
uses: actions/checkout@v7
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '24'
cache: 'npm'
cache-dependency-path: docsite/package-lock.json
- name: Build docsite (install, convert, build)
run: make -C docsite all
- name: Ensure publish configuration is set
run: |
if [ -z "$TARGET_REPO" ]; then
echo '::error::Set the TARGET_REPO environment variable (e.g. owner/marketing-site).'
exit 1
fi
if [ -z "$PUBLISH_TOKEN" ]; then
echo '::error::Add the PUBLISH_TOKEN secret with a PAT that can push to the marketing site repository.'
exit 1
fi
- name: Checkout marketing site repository
uses: actions/checkout@v7
with:
repository: ${{ env.TARGET_REPO }}
token: ${{ env.PUBLISH_TOKEN }}
path: ${{ env.TARGET_WORKDIR }}
ref: ${{ env.TARGET_BRANCH }}
- name: Sync built documentation into marketing site
run: |
mkdir -p "${TARGET_WORKDIR}/${TARGET_DIR}"
rsync -a --delete docsite/build/ "${TARGET_WORKDIR}/${TARGET_DIR}/"
- name: Commit and push updates
run: |
cd "${TARGET_WORKDIR}"
if git status --short "${TARGET_DIR}" | grep .; then
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add "${TARGET_DIR}"
git commit -m "Docs: sync from ${GITHUB_REPOSITORY}@${GITHUB_SHA}"
git push origin "$TARGET_BRANCH"
else
echo "No docsite changes to publish."
fi
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: Publish Docsite on: push: branches: - main paths: - 'docs/**' - 'docsite/**' - '.github/workflows/docsite-publish.yml' workflow_dispatch: env: TARGET_REPO: "containers/ramalama.github.io" TARGET_BRANCH: "main" TARGET_DIR: "public/docs" TARGET_WORKDIR: "ramalama.github.io" PUBLISH_TOKEN: ${{ secrets.DOCSITE_PUBLISH_TOKEN }} concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: publish: timeout-minutes: 30 if: | github.repository_owner == 'containers' runs-on: latchkey-small steps: - name: Checkout RamaLama uses: actions/checkout@v7 - name: Setup Node.js uses: actions/setup-node@v6 with: node-version: '24' cache: 'npm' cache-dependency-path: docsite/package-lock.json - name: Build docsite (install, convert, build) run: make -C docsite all - name: Ensure publish configuration is set run: | if [ -z "$TARGET_REPO" ]; then echo '::error::Set the TARGET_REPO environment variable (e.g. owner/marketing-site).' exit 1 fi if [ -z "$PUBLISH_TOKEN" ]; then echo '::error::Add the PUBLISH_TOKEN secret with a PAT that can push to the marketing site repository.' exit 1 fi - name: Checkout marketing site repository uses: actions/checkout@v7 with: repository: ${{ env.TARGET_REPO }} token: ${{ env.PUBLISH_TOKEN }} path: ${{ env.TARGET_WORKDIR }} ref: ${{ env.TARGET_BRANCH }} - name: Sync built documentation into marketing site run: | mkdir -p "${TARGET_WORKDIR}/${TARGET_DIR}" rsync -a --delete docsite/build/ "${TARGET_WORKDIR}/${TARGET_DIR}/" - name: Commit and push updates run: | cd "${TARGET_WORKDIR}" if git status --short "${TARGET_DIR}" | grep .; then git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" git add "${TARGET_DIR}" git commit -m "Docs: sync from ${GITHUB_REPOSITORY}@${GITHUB_SHA}" git push origin "$TARGET_BRANCH" else echo "No docsite changes to publish." fi
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.
This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.