Skip to content

Commit

Permalink
workflow tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
gphorvath committed Nov 9, 2024
1 parent 9773c54 commit b09c2ad
Showing 1 changed file with 48 additions and 2 deletions.
50 changes: 48 additions & 2 deletions .github/workflows/hugo.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# Sample workflow for building and deploying a Hugo site to GitHub Pages
# Sample workflow for building and deploying a Hugo site to Pages
name: Deploy Hugo site to Pages

on:
# Runs on pushes targeting the default branch
push:
branches: ["main"]
paths:
- 'docs/**' # Only trigger on changes to docs directory
- '.github/workflows/hugo.yml' # And on workflow file changes

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
Expand All @@ -16,7 +19,6 @@ permissions:
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
Expand All @@ -33,21 +35,42 @@ jobs:
env:
HUGO_VERSION: 0.128.0
steps:
# Add cache for Hugo modules and builds
- name: Cache Hugo resources
uses: actions/cache@v3
with:
path: |
${{ runner.temp }}/hugo_cache
./docs/resources
key: ${{ runner.os }}-hugomod-${{ hashFiles('**/go.sum') }}

Check warning on line 45 in .github/workflows/hugo.yaml

View workflow job for this annotation

GitHub Actions / Check Spelling

Unknown word (hugomod)
restore-keys: |
${{ runner.os }}-hugomod-

Check warning on line 47 in .github/workflows/hugo.yaml

View workflow job for this annotation

GitHub Actions / Check Spelling

Unknown word (hugomod)
- 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: Install Dart Sass
run: sudo snap install dart-sass

- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod

Check warning on line 61 in .github/workflows/hugo.yaml

View workflow job for this annotation

GitHub Actions / Check Spelling

Unknown word (Lastmod)

- name: Setup Pages
id: pages
uses: actions/configure-pages@v5

- name: Install Node.js dependencies
run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true"

# Add HTML validation
- name: Setup HTML validation
run: npm install -g html-validator-cli

- name: Build with Hugo
env:
HUGO_CACHEDIR: ${{ runner.temp }}/hugo_cache
Expand All @@ -57,6 +80,23 @@ jobs:
--minify \
--source docs \
--baseURL "${{ steps.pages.outputs.base_url }}/"
# Add error checking
- name: Check for Hugo errors
run: |
if [ -d "./docs/public" ]; then
echo "Build succeeded"
else
echo "Build failed"
exit 1
fi
# Validate HTML output
- name: Validate HTML
run: |
find ./docs/public -name '*.html' -exec html-validator {} \;
continue-on-error: true # Optional: set to false if you want validation errors to fail the build

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
Expand All @@ -73,3 +113,9 @@ jobs:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4

# Add deployment verification
- name: Verify deployment
run: |
curl -s --head --request GET ${{ steps.deployment.outputs.page_url }} | grep "200\|301"
shell: bash

0 comments on commit b09c2ad

Please sign in to comment.