Skip to content

Astro migration

Astro migration #89

Workflow file for this run

name: Build and deploy Astro site to Pages
on:
# Runs on pushes targeting the default branch
push:
branches: ["main"]
# Build (but don't deploy) pull requests, so dependency bumps are tested before merge
pull_request:
branches: ["main"]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
# Allow only one concurrent deployment per ref, skipping runs queued between the run in-progress and latest queued.
# Do NOT cancel in-progress production deployments, but do cancel superseded PR builds.
concurrency:
group: "pages-${{ github.ref }}"
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
build:
runs-on: ubuntu-latest
# Generous limit so a cold build (empty image cache) can finish and seed the cache;
# warm builds take well under a minute.
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v7
with:
node-version: 22
cache: npm
- name: Setup Pages
uses: actions/configure-pages@v6
# Astro keys every generated image on a hash of the source file and the
# transform options, and skips any variant already present in its cache.
# Restoring that cache is the difference between a ~3 minute cold build
# and a ~30 second warm one.
- name: Restore generated images
uses: actions/cache@v6
with:
path: node_modules/.astro
key: astro-assets-${{ hashFiles('src/assets/img/**', 'src/components/Figure.astro', 'src/lib/images.ts') }}
restore-keys: |
astro-assets-
- name: Install dependencies
run: npm ci
- name: Type-check and validate content
# Fails the build on a broken import, a bad component prop, or a post
# whose front matter does not satisfy the content collection schema.
run: npm run check
- name: Build site
run: npm run build
- name: Test built output
# Guards the theme against the ClientRouter's root-attribute swap, which
# neither the type check nor the build can catch.
run: npm test
- name: Upload artifact
uses: actions/upload-pages-artifact@v5
with:
path: ./dist
deploy:
# Deploy only from the default branch, never from pull request builds
if: github.event_name != 'pull_request'
needs: build
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v5