Publishing site Jeu 10 oct 2024 14:29:04 CEST #140
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This GitHub Action builds and serves a Hugo website, checking for build errors on each push to the master branch. | |
# The build status is checked, and if the build fails, the commit is blocked. | |
name: Hugo Build and Status Check | |
# Trigger the workflow on push events to the main branch | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
build: | |
# Use the latest version of Ubuntu as the runner | |
runs-on: ubuntu-latest | |
# Steps to be executed as part of the job | |
steps: | |
# Step to checkout the repository | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
# Step to set up Hugo | |
- name: Setup Hugo | |
uses: peaceiris/actions-hugo@v3 | |
with: | |
# Always use the latest version of Hugo, in case of issue with the latest version, | |
# you can specify a specific version using '0.125.5' | |
hugo-version: 'latest' | |
# Set the extended option to true to install the extended version of Hugo, mandatory for Microcks website | |
extended: true | |
# Step to build the site | |
- name: Build site | |
run: hugo --minify | |
# Capture output and error code | |
continue-on-error: true | |
id: build | |
# Step to start Hugo server in the background | |
- name: Start Hugo server | |
run: hugo server --minify --port=8888 & | |
# Check if build failed | |
- name: Check build status | |
run: | | |
if [ ${{ steps.build.outcome }} != 'success' ]; then | |
echo "::error::Hugo build failed, blocking commit..." | |
exit 1 | |
fi | |
# Stop the Hugo server at the end of the workflow as is running in the background | |
- name: Stop Hugo server | |
run: kill $(lsof -t -i:8888) || true |