Skip to content

refactor: change Netlify CI action #81

refactor: change Netlify CI action

refactor: change Netlify CI action #81

Workflow file for this run

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: ${{ steps.publish.outputs.deploy-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: deploy-info
name: Compute Deploy Info
run: |
set -e
python3 -c 'import base64; print("alias="+base64.urlsafe_b64encode(bytes.fromhex("${{github.sha}}")).decode("utf-8").rstrip("="))' >> "$GITHUB_OUTPUT"
echo "message=`git log -1 --pretty=format:"%s"`" >> "$GITHUB_OUTPUT"
- id: publish
name: Publish to Netlify
uses: nwtgck/[email protected]
with:
publish-dir: .output/public
production-branch: master
github-token: ${{ secrets.GITHUB_TOKEN }}
deploy-message: |
${{ github.event_name == 'pull_request' && format('pr {0}: {1}', github.event.number, steps.deploy-info.outputs.message) || steps.deploy-info.outputs.message }}
alias: ${{ steps.deploy-info.outputs.alias }}
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
timeout-minutes: 1