Changelog 5ad4e0b
gh pages deploy
2 files of code, design or docs +59 −1 lines
Code, design and documents 2 files
.github/workflows/deploy.yml +49 −0
@@ -0,0 +1,49 @@ +name: Deploy to GitHub Pages + +on: + push: + branches: [main] + workflow_dispatch: + +# Let the workflow publish to Pages using GitHub's own token. +permissions: + contents: read + pages: write + id-token: write + +# One deployment at a time; let a running deployment finish. +concurrency: + group: pages + cancel-in-progress: false + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v7 + - uses: actions/setup-node@v7 + with: + node-version: 22 + cache: npm + - id: pages + uses: actions/configure-pages@v6 + - run: npm ci + # The site URL and sub-path come from the repository's Pages settings, so the + # same build works for user.github.io/repo and for a custom domain. + - run: npm run build + env: + SITE: ${{ steps.pages.outputs.origin }} + BASE_PATH: ${{ steps.pages.outputs.base_path }} + - uses: actions/upload-pages-artifact@v5 + with: + path: dist + + deploy: + needs: build + runs-on: ubuntu-latest + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + steps: + - id: deployment + uses: actions/deploy-pages@v5
astro.config.mjs +10 −1
@@ -2,3 +2,12 @@ import { defineConfig } from "astro/config"; // Fully static output: one HTML file per page, including one per country. -export default defineConfig({}); +// +// SITE and BASE_PATH are set by the GitHub Pages workflow (e.g. BASE_PATH="/cannabis-freedom-index" +// for a project site). Locally both are unset and the site is served from "/". +// The base always ends with a slash because links are built as `${base}country/…`. +const base = (process.env.BASE_PATH || "").replace(/\/+$/, "") + "/"; + +export default defineConfig({ + site: process.env.SITE || undefined, + base, +});