Skip to content

Deploy to GitHub Pages #207

Deploy to GitHub Pages

Deploy to GitHub Pages #207

Workflow file for this run

name: Deploy to GitHub Pages
on:
push:
branches: [main, master]
workflow_dispatch:
# Hourly: refresh the near-real-time live overlay and redeploy.
schedule:
- cron: "17 * * * *"
# Allow the workflow to publish to Pages.
permissions:
contents: read
pages: write
id-token: write
# One concurrent deployment; don't cancel an in-progress production deploy.
concurrency:
group: pages
cancel-in-progress: false
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- name: Install dependencies
run: npm ci
# Optional: regenerate the annual dataset from the open-data feeds so each
# deploy is freshly dated. Falls back to the committed src/data/countries.json
# if a source is unreachable in CI. (Skipped on the hourly schedule — the
# annual data doesn't change that often.)
- name: Refresh annual data (best-effort)
if: github.event_name != 'schedule'
run: npm run build:data || echo "annual data refresh skipped — using committed dataset"
# Near-real-time overlay (UK works with no token; US/EU activate when the
# EIA_KEY / ENTSOE_TOKEN secrets are set). Baked into the build, not committed.
- name: Refresh live data (best-effort)
env:
EIA_KEY: ${{ secrets.EIA_KEY }}
ENTSOE_TOKEN: ${{ secrets.ENTSOE_TOKEN }}
run: npm run build:live || echo "live refresh skipped — empty overlay"
- name: Build
run: npm run build
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: dist
deploy:
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy
id: deployment
uses: actions/deploy-pages@v4