Deploy Blogpost Pages workflow (microsoft/memento)
The Deploy Blogpost Pages workflow from microsoft/memento, explained and optimized by Latchkey.
A
CI health: A - excellent
Point runs-on at Latchkey and get job timeouts, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the Deploy Blogpost Pages workflow from the microsoft/memento 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: Deploy Blogpost Pages
on:
push:
branches:
- main
paths:
- blogpost/**
- .github/workflows/static.yml
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: pages
cancel-in-progress: true
jobs:
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Configure GitHub Pages
uses: actions/configure-pages@v5
- name: Build Pages artifact
run: |
set -eu
mkdir -p _site/blogpost
cp blogpost/index.html _site/blogpost/
cp -R blogpost/css _site/blogpost/
cp -R blogpost/figures _site/blogpost/
printf '' > _site/.nojekyll
cat > _site/index.html <<'EOF'
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="refresh" content="0; url=./blogpost/">
<title>Memento Blogpost Redirect</title>
<link rel="canonical" href="./blogpost/">
</head>
<body>
<p>Redirecting to <a href="./blogpost/">the Memento blogpost</a>.</p>
</body>
</html>
EOF
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: _site
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v5
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: Deploy Blogpost Pages on: push: branches: - main paths: - blogpost/** - .github/workflows/static.yml workflow_dispatch: permissions: contents: read pages: write id-token: write concurrency: group: pages cancel-in-progress: true jobs: deploy: timeout-minutes: 30 environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} runs-on: latchkey-small steps: - name: Check out repository uses: actions/checkout@v4 - name: Configure GitHub Pages uses: actions/configure-pages@v5 - name: Build Pages artifact run: | set -eu mkdir -p _site/blogpost cp blogpost/index.html _site/blogpost/ cp -R blogpost/css _site/blogpost/ cp -R blogpost/figures _site/blogpost/ printf '' > _site/.nojekyll cat > _site/index.html <<'EOF' <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="refresh" content="0; url=./blogpost/"> <title>Memento Blogpost Redirect</title> <link rel="canonical" href="./blogpost/"> </head> <body> <p>Redirecting to <a href="./blogpost/">the Memento blogpost</a>.</p> </body> </html> EOF - name: Upload Pages artifact uses: actions/upload-pages-artifact@v3 with: path: _site - name: Deploy to GitHub Pages id: deployment uses: actions/deploy-pages@v5
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.
This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.