Skip to content

Build and Deploy Static Site #110

Build and Deploy Static Site

Build and Deploy Static Site #110

Workflow file for this run

name: Build and Deploy Static Site
on:
# Trigger on push to main branch
push:
branches:
- main
# Allow manual trigger from Actions tab
workflow_dispatch:
# Trigger on a schedule twice daily to refresh data from OSM
schedule:
- cron: '0 2,14 * * *' # Run at 2am and 2pm UTC daily (every 12 hours)
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
# Allow one concurrent deployment
concurrency:
group: "pages"
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
environment: prod
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build static site
env:
# OSM API credentials from repository secrets
OSM_API_ID: ${{ secrets.OSM_API_KEY }}
OSM_API_TOKEN: ${{ secrets.OSM_API_TOKEN }}
OSM_SECTION_ID: ${{ secrets.OSM_SECTION_ID || '1' }}
OSM_TERM_ID: ${{ secrets.OSM_TERM_ID || '1' }}
OSM_SECTION_TYPE: ${{ secrets.OSM_SECTION_TYPE || 'scouts' }}
# Site configuration
NEXT_PUBLIC_SITE_URL: ${{ vars.SITE_URL || 'https://walkhamvalleyscouts.org.uk' }}
# Optional: Use mock data if secrets are not configured
# Uncomment this line to build with mock data:
USE_MOCK_DATA: true
run: npm run build
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./out
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4