|
| 1 | +# Workflow for deploying the site to GitHub Pages |
| 2 | +# Copied from: https://gohugo.io/hosting-and-deployment/hosting-on-github/ |
| 3 | +name:Deploy Hugo site to Pages |
| 4 | + |
| 5 | +on: |
| 6 | +# Runs on pushes targeting the default branch |
| 7 | +push: |
| 8 | +branches: |
| 9 | + -main |
| 10 | + |
| 11 | +# Allows you to run this workflow manually from the Actions tab |
| 12 | +workflow_dispatch: |
| 13 | + |
| 14 | +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages |
| 15 | +permissions: |
| 16 | +contents:read |
| 17 | +pages:write |
| 18 | +id-token:write |
| 19 | + |
| 20 | +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. |
| 21 | +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. |
| 22 | +concurrency: |
| 23 | +group:"pages" |
| 24 | +cancel-in-progress:false |
| 25 | + |
| 26 | +# Default to bash |
| 27 | +defaults: |
| 28 | +run: |
| 29 | +shell:bash |
| 30 | + |
| 31 | +jobs: |
| 32 | +# Build job |
| 33 | +build: |
| 34 | +runs-on:ubuntu-latest |
| 35 | +env: |
| 36 | +HUGO_VERSION:0.128.0 |
| 37 | +steps: |
| 38 | + -name:Install Hugo CLI |
| 39 | +run:| |
| 40 | + wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \ |
| 41 | + && sudo dpkg -i ${{ runner.temp }}/hugo.deb |
| 42 | + -name:Install Dart Sass |
| 43 | +run:sudo snap install dart-sass |
| 44 | + -name:Checkout |
| 45 | +uses:actions/checkout@v4 |
| 46 | +with: |
| 47 | +submodules:recursive |
| 48 | +fetch-depth:0 |
| 49 | + -name:Setup Pages |
| 50 | +id:pages |
| 51 | +uses:actions/configure-pages@v5 |
| 52 | + -name:Install Node.js dependencies |
| 53 | +run:"[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true" |
| 54 | + -name:Build with Hugo |
| 55 | +env: |
| 56 | +HUGO_CACHEDIR:${{ runner.temp }}/hugo_cache |
| 57 | +HUGO_ENVIRONMENT:production |
| 58 | +TZ:America/Los_Angeles |
| 59 | +run:| |
| 60 | + hugo \ |
| 61 | + --gc \ |
| 62 | + --minify \ |
| 63 | + --baseURL "${{ steps.pages.outputs.base_url }}/" |
| 64 | + -name:Upload artifact |
| 65 | +uses:actions/upload-pages-artifact@v3 |
| 66 | +with: |
| 67 | +path:./public |
| 68 | + |
| 69 | +# Deployment job |
| 70 | +deploy: |
| 71 | +environment: |
| 72 | +name:github-pages |
| 73 | +url:${{ steps.deployment.outputs.page_url }} |
| 74 | +runs-on:ubuntu-latest |
| 75 | +needs:build |
| 76 | +steps: |
| 77 | + -name:Deploy to GitHub Pages |
| 78 | +id:deployment |
| 79 | +uses:actions/deploy-pages@v4 |