Skip to content

Commit

Permalink
refactor: Update GitHub Pages workflow for deploying website
Browse files Browse the repository at this point in the history
  • Loading branch information
berntpopp committed Sep 8, 2024
1 parent aff9b39 commit b7352ae
Showing 1 changed file with 31 additions and 42 deletions.
73 changes: 31 additions & 42 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
@@ -1,51 +1,40 @@
# Simple workflow for deploying static content to GitHub Pages
name: Deploy static content to Pages
# based onhttps://github.com/horosin/pages-deploy
name: github pages

on:
# Runs on pushes targeting the default branch
push:
branches: ['main']

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets the GITHUB_TOKEN permissions 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
branches:
- main
pull_request:

jobs:
# Single deploy job since we're just deploying
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v4
- uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 20
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
node-version: '20'

- name: Cache dependencies
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- run: npm ci
- run: NODE_ENV=production npm run build
- run: cp dist/index.html dist/404.html

- name: Deploy
uses: peaceiris/actions-gh-pages@v3
if: ${{ github.ref == 'refs/heads/main' }}
with:
# Upload dist folder
path: './dist'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./dist

0 comments on commit b7352ae

Please sign in to comment.