diff --git a/.env.example b/.env.example index 38f90cb6..427b9616 100644 --- a/.env.example +++ b/.env.example @@ -1,14 +1,15 @@ -# Hosted form endpoint used by the contact form. -# Examples: Formspree, Basin, Getform, or a self-hosted POST endpoint. +# Optional override for the hosted contact-form endpoint configured in src/config/contact.ts. PUBLIC_CONTACT_FORM_ENDPOINT= # Optional comma-separated fallback recipients used by the mailto fallback. PUBLIC_CONTACT_RECIPIENTS=directors@familyfed.ie,info@familyfed.ie,media@familyfed.ie -# Optional admin URL for reviewing stored contact form submissions. +# Optional override for the submissions URL configured in src/config/contact.ts. PUBLIC_CONTACT_SUBMISSIONS_URL= -# Optional Plausible analytics configuration. +# Optional override for the Cloudflare Web Analytics dashboard link in admin. +PUBLIC_ANALYTICS_DASHBOARD_URL= + +# Optional Plausible tracking in addition to Cloudflare Web Analytics. PUBLIC_PLAUSIBLE_DOMAIN=familyfed.ie PUBLIC_PLAUSIBLE_SCRIPT_SRC=https://plausible.io/js/script.js -PUBLIC_ANALYTICS_DASHBOARD_URL= diff --git a/.forgejo/workflows/deploy.yml b/.forgejo/workflows/deploy.yml index 89777ee4..86ffca93 100644 --- a/.forgejo/workflows/deploy.yml +++ b/.forgejo/workflows/deploy.yml @@ -1,60 +1,87 @@ +name: Build and publish static site + on: push: - branches: [main] workflow_dispatch: concurrency: - group: deploy-main + group: site-${{ github.ref }} cancel-in-progress: true jobs: - deploy: - runs-on: self-hosted + build: + runs-on: docker + container: + image: node:24-bookworm + timeout-minutes: 30 + env: + NODE_OPTIONS: --max-old-space-size=768 + PUBLIC_ANALYTICS_DASHBOARD_URL: ${{ secrets.PUBLIC_ANALYTICS_DASHBOARD_URL }} + PUBLIC_CONTACT_FORM_ENDPOINT: ${{ secrets.PUBLIC_CONTACT_FORM_ENDPOINT }} + PUBLIC_CONTACT_RECIPIENTS: ${{ secrets.PUBLIC_CONTACT_RECIPIENTS }} + PUBLIC_CONTACT_SUBMISSIONS_URL: ${{ secrets.PUBLIC_CONTACT_SUBMISSIONS_URL }} + PUBLIC_PLAUSIBLE_DOMAIN: ${{ secrets.PUBLIC_PLAUSIBLE_DOMAIN }} + PUBLIC_PLAUSIBLE_SCRIPT_SRC: ${{ secrets.PUBLIC_PLAUSIBLE_SCRIPT_SRC }} steps: - - name: Build Astro and restart Nomad - env: - NOMAD_ADDR: ${{ secrets.NOMAD_ADDR }} - NOMAD_TOKEN: ${{ secrets.NOMAD_TOKEN }} - PUBLIC_ANALYTICS_DASHBOARD_URL: ${{ secrets.PUBLIC_ANALYTICS_DASHBOARD_URL }} - PUBLIC_CONTACT_FORM_ENDPOINT: ${{ secrets.PUBLIC_CONTACT_FORM_ENDPOINT }} - PUBLIC_CONTACT_RECIPIENTS: ${{ secrets.PUBLIC_CONTACT_RECIPIENTS }} - PUBLIC_CONTACT_SUBMISSIONS_URL: ${{ secrets.PUBLIC_CONTACT_SUBMISSIONS_URL }} - PUBLIC_PLAUSIBLE_DOMAIN: ${{ secrets.PUBLIC_PLAUSIBLE_DOMAIN }} - PUBLIC_PLAUSIBLE_SCRIPT_SRC: ${{ secrets.PUBLIC_PLAUSIBLE_SCRIPT_SRC }} - REPO_URL: https://git.bcgen.ie/familyfedie/familyfedie-website.git + - uses: actions/checkout@v4 + + - name: Install validation tools + run: | + apt-get update -qq + apt-get install -y -q python3 + + - name: Install dependencies + run: npm ci --no-audit --no-fund + + - name: Build and validate Astro output + run: npm run check + + - name: Split public and protected admin bundles run: | set -eu - rm -rf source - export REF_NAME="${GITHUB_REF_NAME:-main}" + rm -rf bundle-public bundle-admin + mkdir -p bundle-public bundle-admin/admin bundle-admin/css + cp -a dist/. bundle-public/ + rm -rf bundle-public/admin bundle-public/admin.html + test ! -e bundle-public/admin + test ! -e bundle-public/admin.html - nix --extra-experimental-features "nix-command flakes" \ - shell nixpkgs#git \ - -c git clone --depth 1 --branch "$REF_NAME" "$REPO_URL" source + cp dist/admin/index.html bundle-admin/index.html + cp dist/admin/index.html bundle-admin/admin/index.html + cp -a dist/admin/content bundle-admin/admin/content + cp dist/css/admin.css bundle-admin/css/admin.css - cd source - nix --extra-experimental-features "nix-command flakes" \ - shell nixpkgs#nodejs_24 \ - -c npm ci - rm -rf dist - nix --extra-experimental-features "nix-command flakes" \ - shell nixpkgs#nodejs_24 \ - -c npm run build + - name: Install Garage publishing tools + if: github.ref == 'refs/heads/main' + run: | + set -eu + apt-get update -qq + apt-get install -y -q ca-certificates python3-venv + python3 -m venv /opt/awscli + /opt/awscli/bin/pip install --quiet awscli - test -f dist/index.html - test -f dist/admin/index.html - test -f dist/speeches/index.html - test -f dist/assets/icons/familyfed-favicon.png + - name: Publish main to Garage + if: github.ref == 'refs/heads/main' + env: + AWS_ACCESS_KEY_ID: ${{ secrets.GARAGE_REPLICATED_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.GARAGE_REPLICATED_SECRET_ACCESS_KEY }} + AWS_DEFAULT_REGION: garage-replicated + GARAGE_S3_ENDPOINT: https://s3-replicated.bcgen.ie + run: | + set -eu + aws=/opt/awscli/bin/aws + common="--endpoint-url $GARAGE_S3_ENDPOINT --no-progress" - ALLOC_ID=$(nix --extra-experimental-features "nix-command flakes" \ - shell nixpkgs#curl nixpkgs#jq \ - -c sh -c 'curl -sf -H "X-Nomad-Token: $NOMAD_TOKEN" "$NOMAD_ADDR/v1/job/familyfed/allocations" | jq -r "map(select(.ClientStatus == \"running\"))[0].ID"') + $aws $common s3 sync bundle-public s3://familyfed.ie --delete \ + --cache-control 'public, max-age=3600, must-revalidate' + $aws $common s3 cp bundle-public s3://familyfed.ie --recursive \ + --exclude '*' --include '*.html' \ + --cache-control 'public, max-age=0, must-revalidate' + $aws $common s3 cp bundle-public s3://familyfed.ie --recursive \ + --exclude '*' --include '*.json' \ + --cache-control 'public, max-age=0, must-revalidate' - test -n "$ALLOC_ID" - test "$ALLOC_ID" != "null" - echo "Stopping allocation to trigger fresh prestart: $ALLOC_ID" - nix --extra-experimental-features "nix-command flakes" \ - shell nixpkgs#curl \ - -c curl -sf -X POST \ - -H "X-Nomad-Token: $NOMAD_TOKEN" \ - "$NOMAD_ADDR/v1/allocation/$ALLOC_ID/stop" - echo "Deploy triggered. Nomad will schedule a new alloc that re-fetches the site." + $aws $common s3 sync bundle-admin s3://admin.familyfed.ie --delete \ + --cache-control 'private, max-age=0, must-revalidate' + $aws $common s3 cp bundle-admin s3://admin.familyfed.ie --recursive \ + --cache-control 'private, no-store' diff --git a/AGENTS.md b/AGENTS.md index c0efa389..cc02b214 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -14,6 +14,9 @@ migration continues. ## Working Rules - All files in this repository may be changed when needed. +- For requested website changes, deploy the completed change to the live site by + default. Do not start or present a local preview unless the user explicitly + asks for one. - When the user says to move something, move it. Do not only copy it or create a parallel structure unless the user specifically asks for a copy. - If moving files requires updating links, imports, scripts, stylesheets, image @@ -21,6 +24,8 @@ migration continues. - Keep the structure simple and close to what the user asks for. - `.forgejo/` and deployment configuration are not special unless the user says they are. +- Feature-branch Actions build and validate only. Production Garage publishing + is restricted to commits on `main`. ## Repo Map diff --git a/README.md b/README.md index 8f6dd6e3..d06b59f3 100644 --- a/README.md +++ b/README.md @@ -110,13 +110,18 @@ http://localhost:4321/ ## Deployment -This project deploys as a static Astro build. A deployment job should install -dependencies, run the build, and publish the generated `dist/` directory: +This project deploys as a static Astro build through Forgejo Actions. Every +branch push installs dependencies, builds the complete site, audits its links, +and prepares the separate public and protected-admin bundles. Feature branches +never receive Garage publishing credentials and never change production. + +Only commits on `main` synchronize the validated bundles to `familyfed.ie` and +`admin.familyfed.ie` in Garage. A manual workflow dispatch is subject to the +same branch guard: dispatching a feature branch builds it but cannot publish it. + +The equivalent local validation is: ```bash npm ci -npm run build +npm run check ``` - -Use `npm run start` only when you intentionally want Astro to serve the built -output in an environment such as a local or Nomad preview job. diff --git a/archive-source/2013-sunday-service-archive.html b/archive-source/2013-sunday-service-archive.html index 9ffa191c..173a666e 100644 --- a/archive-source/2013-sunday-service-archive.html +++ b/archive-source/2013-sunday-service-archive.html @@ -7,8 +7,11 @@
This page has moved to /archive/sunday-services/2013/.
+