52 lines
1.6 KiB
YAML
52 lines
1.6 KiB
YAML
name: Build and Deploy
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
|
|
permissions:
|
|
contents: read
|
|
pages: write
|
|
id-token: write
|
|
|
|
jobs:
|
|
# Build job
|
|
build:
|
|
# cf. https://stackoverflow.com/questions/64781462/github-actions-default-branch-variable
|
|
# Run job only on default branch (as $default_branch variable only works on
|
|
# workflow templates)
|
|
if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
- name: Setup Pages
|
|
id: pages
|
|
uses: actions/configure-pages@v5
|
|
- name: Install and Build 🔧 # This example project is built using npm and outputs the result to the 'build' folder. Replace with the commands required to build your project, or remove this step entirely if your site is pre-built.
|
|
run: |
|
|
npm install
|
|
npm run build
|
|
- name: Upload artifact
|
|
uses: actions/upload-pages-artifact@v3
|
|
with:
|
|
path: '.'
|
|
|
|
# Deployment job
|
|
deploy:
|
|
# cf. https://stackoverflow.com/questions/64781462/github-actions-default-branch-variable
|
|
# Run job only on default branch (as $default_branch variable only works on
|
|
# workflow templates)
|
|
if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
|
|
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
|