-
-
Notifications
You must be signed in to change notification settings - Fork 37
54 lines (45 loc) · 1.7 KB
/
hugo-build-status-check.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# 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