Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/actions/build-site/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: "Build Hugo Site"
description: "Shared Hugo build logic"

runs:
using: "composite"
steps:
- name: Install Hugo CLI
shell: bash
env:
HUGO_VERSION: "0.152.2"
run: |
wget -O ${{ runner.temp }}/hugo.deb \
https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \
&& sudo dpkg -i ${{ runner.temp }}/hugo.deb
- name: Build with Hugo
shell: bash
env:
# For backward compatibility with Hugo modules
HUGO_ENVIRONMENT: production
HUGO_ENV: production
run: |
hugo --gc --minify --baseURL "$BASE_URL"

21 changes: 21 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Builds but does not deploy, for pull request validation.

name: build

on:
# Runs on pull requests
pull_request:

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
submodules: recursive
fetch-depth: 0
- name: Build site
uses: ./.github/actions/build-site
env:
BASE_URL: "https://example.com/"
58 changes: 15 additions & 43 deletions .github/workflows/hugo.yaml → .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Builds and deploys the site to GitHub Pages.
# Does NOT run on pull requests.

name: build-and-deploy

on:
Expand All @@ -6,9 +9,6 @@ on:
branches:
- master

# Runs on pull requests
pull_request:

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

Expand All @@ -24,56 +24,28 @@ concurrency:
group: "pages"
cancel-in-progress: false

# Default to bash
defaults:
run:
shell: bash

jobs:
# Build job
build:
# Deployment job
build-and-deploy:
runs-on: ubuntu-latest
env:
HUGO_VERSION: 0.152.2
permissions:
contents: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Install Hugo CLI
run: |
wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \
&& sudo dpkg -i ${{ runner.temp }}/hugo.deb
- name: Checkout
uses: actions/checkout@v6
with:
submodules: recursive
fetch-depth: 0
- name: Build with Hugo
- name: Build site
uses: ./.github/actions/build-site
env:
# For maximum backward compatibility with Hugo modules
HUGO_ENVIRONMENT: production
HUGO_ENV: production
run: |
hugo \
--gc \
--minify \
--baseURL "${{ steps.pages.outputs.base_url }}/"
- name: Upload artifact
uses: actions/upload-pages-artifact@v4
with:
path: ./public

# Deployment job
deploy:
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
permissions:
contents: write
needs: build
steps:
- name: Deploy to GitHub Pages
BASE_URL: "${{ steps.pages.outputs.base_url }}/"
- name: Deploy
id: deployment
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
github_token: ${{ secrets.GITHUB_TOKEN }}