Build and deploy website #44
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: | |
workflow_run: | |
workflows: [Hackney Cinema Calendar] | |
types: [completed] | |
workflow_dispatch: | |
name: Build and deploy website | |
# 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, skipping runs queued between the run in-progress and latest queued. | |
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. | |
concurrency: | |
group: "pages" | |
cancel-in-progress: false | |
jobs: | |
build: | |
name: Build Next.js site | |
runs-on: ubuntu-latest | |
env: | |
MOVIEDB_API_KEY: ${{ secrets.MOVIEDB_API_KEY }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version-file: .node-version | |
- uses: actions/configure-pages@v5 | |
with: | |
static_site_generator: next | |
generator_config_file: ./site/next.config.ts | |
- name: Restore cache | |
uses: actions/cache@v4 | |
with: | |
path: | | |
./site/.next/cache | |
# Generate a new cache whenever packages or source files change. | |
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }} | |
# If source files changed but packages didn't, rebuild from a prior cache. | |
restore-keys: | | |
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}- | |
- run: npm ci # Install the script dependencies | |
- name: Pull data from latest release | |
run: npm run populate:output | |
- name: Generate combined compressed blob | |
run: npm run generate:combined-data | |
- run: npm ci # Install the site dependencies | |
working-directory: ./site | |
- run: NEXT_PUBLIC_GENERATED_AT=$(TZ=Europe/London date +%s) npm run build | |
working-directory: ./site | |
- uses: actions/upload-pages-artifact@v3 | |
with: | |
path: ./site/out | |
deploy: | |
name: Deploy site | |
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 |