Skip to content

Deploy Hugo site to Pages #324

Deploy Hugo site to Pages

Deploy Hugo site to Pages #324

Workflow file for this run

name: Deploy Hugo site to Pages
on:
push:
branches: ["main"]
workflow_dispatch:
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: write
pages: write
id-token: write
# Allow one concurrent deployment
concurrency:
group: "pages"
cancel-in-progress: true
defaults:
run:
shell: bash
env:
baseURL: "https://smcleod.net"
jobs:
build:
if: github.repository == 'sammcj/smcleod'
strategy:
matrix:
environment: ['production']
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
submodules: recursive
- name: Setup Pages
id: pages
uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5
- name: Setup Hugo
uses: peaceiris/actions-hugo@75d2e84710de30f6ff7268e08f310b60ef14033f # v3
with:
hugo-version: 'latest'
extended: true
- name: Build
run: |
hugo \
--minify \
--baseURL "${{ env.baseURL }}"
env:
HUGO_ENVIRONMENT: ${{ matrix.environment }}
HUGO_ENV: ${{ matrix.environment }}
- name: Prepare tag
id: prepare_tag
if: startsWith(github.ref, 'refs/tags/')
run: |
TAG_NAME="${GITHUB_REF##refs/tags/}"
echo "tag_name=${TAG_NAME}" >> $GITHUB_OUTPUT
echo "deploy_tag_name=deploy-${TAG_NAME}" >> $GITHUB_OUTPUT
- name: Upload artifact
uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3
with:
path: ./public
# Deploy job
deploy:
needs: build
if: github.ref == 'refs/heads/main' && github.repository == 'sammcj/smcleod'
runs-on: ubuntu-22.04
environment:
name: github-pages
url: ${{ env.baseURL }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4
# Deploy job
deploy-staging:
needs: build
if: github.ref == 'refs/heads/main' && github.repository == 'sammcj/smcleod-hugo'
runs-on: ubuntu-22.04
environment:
name: github-pages
url: ${{ env.baseURL }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4