chore: switch CI to Netlify #78
Workflow file for this run
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
name: Pages | |
on: | |
push: | |
branches: | |
- 'pages/**' # branch pattern for pages-only changes | |
# Enable running this workflow from ci.yml | |
workflow_call: | |
inputs: | |
ci: | |
description: 'Used to dinstinguish a CI workflow call from a standalone workflow' | |
type: boolean | |
required: false | |
default: true | |
# Enable running this workflow manually from the Actions tab | |
workflow_dispatch: | |
# 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: | |
bundle: | |
name: Bundle Manifest | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Download Testbed Results (CI) | |
if: inputs.ci | |
uses: actions/download-artifact@v3 | |
with: | |
name: results | |
- name: Download Testbed Results (Standalone) | |
if: (!inputs.ci) | |
run: gh run download -n results | |
env: | |
GH_TOKEN: ${{ github.token }} | |
- name: Download Index (CI) | |
if: inputs.ci | |
uses: actions/download-artifact@v3 | |
with: | |
name: index | |
- name: Download Index (Standalone) | |
if: (!inputs.ci) | |
run: gh run download -n index | |
env: | |
GH_TOKEN: ${{ github.token }} | |
- name: Create Manifest | |
run: ./bundle.py index.json results.json -o manifest.json | |
- name: Upload Manifest | |
uses: actions/upload-artifact@v3 | |
with: | |
name: manifest | |
path: manifest.json | |
if-no-files-found: error | |
deploy: | |
needs: bundle | |
name: Deploy | |
environment: | |
name: netlify | |
url: ${{ github.ref_name == 'master' && steps.publish.outputs.NETLIFY_LIVE_URL || steps.publish.outputs.NETLIFY_URL }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Download Manifest | |
uses: actions/download-artifact@v3 | |
with: | |
name: manifest | |
path: site | |
- name: Install Node Modules | |
run: npm ci | |
- name: Build Site | |
run: npm run generate | |
- id: alias | |
name: Compute Deploy Alias | |
if: github.ref_name != 'master' | |
run: python3 -c 'import base64; print("alias="+base64.urlsafe_b64encode(bytes.fromhex("${{github.sha}}")).decode("utf-8").rstrip("="))' >> "$GITHUB_OUTPUT" | |
- id: publish | |
name: Publish | |
uses: netlify/actions/cli@master | |
with: | |
args: deploy --dir=.output/public \ | |
${{ github.ref_name == 'master' && '--prod' || format('--alias={0}', steps.alias.outputs.alias) }} | |
env: | |
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} | |
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} |