Skip to content

Hugo build and deploy #733

Hugo build and deploy

Hugo build and deploy #733

Workflow file for this run

name: Hugo build and deploy
on:
push:
branches: [ main ]
paths:
- '.github/workflows/deploy.yml'
- 'assets/**'
- 'config/**'
- 'content/**'
- 'data/**'
- 'static/**'
- 'themes/**'
- 'go.mod'
- 'go.sum'
workflow_run:
workflows: ['Update theme']
types:
- completed
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:
# Build job
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Cache Hugo resources
uses: actions/cache@v4
env:
cache-name: cache-hugo-resources
with:
path: resources
key: ${{ env.cache-name }}
- uses: actions/setup-go@v5
with:
go-version: "^1.17.0"
- run: go version
- name: Cache Go Modules
uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Setup Hugo
uses: peaceiris/actions-hugo@v3
with:
# use the environment variable HUGO_VERSION as the hugo version, if not set, use `latest`.
hugo-version: ${{ vars.HUGO_VERSION || 'latest' }}
extended: true
- name: Hugo build
run: hugo --gc --minify --logLevel info
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
# Upload only the public directory
path: './public'
# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4