Deploy to GitHub Pages #4
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: Deploy to GitHub Pages | |
on: | |
# Run on tag pushes matching starting with 'v' | |
push: | |
tags: | |
- 'v*' | |
# ... Also run manually | |
workflow_dispatch: | |
# 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 | |
# Default to bash | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
# Build job | |
build: | |
runs-on: ubuntu-22.04 | |
timeout-minutes: 10 | |
permissions: | |
contents: write | |
pull-requests: read | |
env: | |
INPUT_PATH: "." | |
steps: | |
- name: Checkout | |
uses: actions/[email protected] | |
- name: Set up Node.js | |
uses: actions/[email protected] | |
with: | |
node-version: '20.9.x' | |
- name: Install dependencies | |
run: npm clean-install | |
- name: Build | |
run: npm run build | |
- name: Fix permissions | |
run: | | |
chmod -c -R +rX "$INPUT_PATH" | while read line; do | |
echo "::warning title=Invalid file permissions automatically fixed::$line" | |
done | |
- name: Archive artifact | |
shell: sh | |
run: | | |
echo ::group::Archive artifact | |
tar \ | |
--dereference --hard-dereference \ | |
--directory "$INPUT_PATH" \ | |
-cvf "$RUNNER_TEMP/artifact.tar" \ | |
--exclude=.git \ | |
--exclude=.github \ | |
--exclude=*/node_modules/* \ | |
--exclude=node_modules/* \ | |
$(test -f ../.releaseignore && echo "--exclude-from=../.releaseignore") \ | |
. | |
echo ::endgroup:: | |
- name: Upload artifact | |
id: upload-artifact | |
uses: actions/[email protected] | |
with: | |
name: github-pages | |
path: ${{ runner.temp }}/artifact.tar | |
retention-days: 1 | |
if-no-files-found: error | |
deploy: | |
needs: build | |
runs-on: ubuntu-22.04 | |
timeout-minutes: 10 | |
permissions: | |
pages: write # to deploy to Pages | |
id-token: write # to verify the deployment originates from an appropriate source | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/[email protected] |