Deploy to GitHub Pages workflow (pathintegral-institute/mcpm.sh)
The Deploy to GitHub Pages workflow from pathintegral-institute/mcpm.sh, explained and optimized by Latchkey.
CI health: B - good
Point runs-on at Latchkey and get job timeouts, SHA-pinned actions, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the Deploy to GitHub Pages workflow from the pathintegral-institute/mcpm.sh 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
name: Deploy to GitHub Pages
on:
push:
branches:
- main
workflow_dispatch:
schedule:
- cron: '0 */6 * * *' # Run every 6 hours
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
validate:
uses: ./.github/workflows/test.yml
build:
runs-on: ubuntu-latest
needs: validate
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Install uv with caching
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
cache-dependency-glob: "pyproject.toml"
- name: Install dependencies
run: |
uv sync --group dev
- name: Setup site structure
run: |
mkdir -p pages/registry
mkdir -p pages/api/servers
- name: Run preparation script
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
chmod +x ./scripts/prepare.sh
source .venv/bin/activate
./scripts/prepare.sh ./pages
- name: Build with Jekyll
uses: actions/jekyll-build-pages@v1
with:
source: ./pages
destination: ./_site
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
deploy-cloudflare:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: github-pages
path: ./dist
- name: Extract artifact
run: |
tar -xf ./dist/artifact.tar -C ./dist
rm ./dist/artifact.tar
- name: Deploy to Cloudflare Pages
uses: cloudflare/pages-action@v1
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: mcpm-sh
directory: ./dist
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: Deploy to GitHub Pages on: push: branches: - main workflow_dispatch: schedule: - cron: '0 */6 * * *' # Run every 6 hours permissions: contents: read pages: write id-token: write concurrency: group: "pages" cancel-in-progress: false jobs: validate: timeout-minutes: 30 uses: ./.github/workflows/test.yml build: timeout-minutes: 30 runs-on: latchkey-small needs: validate steps: - name: Checkout uses: actions/checkout@v4 - name: Setup Pages uses: actions/configure-pages@v5 - name: Install uv with caching uses: astral-sh/setup-uv@v5 with: enable-cache: true cache-dependency-glob: "pyproject.toml" - name: Install dependencies run: | uv sync --group dev - name: Setup site structure run: | mkdir -p pages/registry mkdir -p pages/api/servers - name: Run preparation script env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | chmod +x ./scripts/prepare.sh source .venv/bin/activate ./scripts/prepare.sh ./pages - name: Build with Jekyll uses: actions/jekyll-build-pages@v1 with: source: ./pages destination: ./_site - name: Upload artifact uses: actions/upload-pages-artifact@v3 deploy: timeout-minutes: 30 environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} runs-on: latchkey-small needs: build steps: - name: Deploy to GitHub Pages id: deployment uses: actions/deploy-pages@v4 deploy-cloudflare: timeout-minutes: 30 runs-on: latchkey-small needs: build steps: - name: Checkout uses: actions/checkout@v4 - name: Download artifact uses: actions/download-artifact@v4 with: name: github-pages path: ./dist - name: Extract artifact run: | tar -xf ./dist/artifact.tar -C ./dist rm ./dist/artifact.tar - name: Deploy to Cloudflare Pages uses: cloudflare/pages-action@v1 with: apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} projectName: mcpm-sh directory: ./dist
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. - Add a job timeout so a hung step cannot burn hours of runner time.
2 third-party actions are referenced by a movable tag. Pin them to the commit SHA (Latchkey resolves and applies this automatically) so a repointed tag cannot change what runs.
This workflow runs 4 jobs per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.