Skip to content

Commit f54d5fb

Browse files
authored
Update hugo-pages.yml (#81)
1 parent 558d98a commit f54d5fb

File tree

1 file changed

+69
-40
lines changed

1 file changed

+69
-40
lines changed

.github/workflows/hugo-pages.yml

Lines changed: 69 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,99 @@
1-
# Sample workflow for building and deploying a Hugo site to GitHub Pages
2-
name: Deploy Hugo site to Pages
3-
1+
name: Hugo Build and deploy
42
on:
5-
# Runs on pushes targeting the default branch
63
push:
7-
branches: ["main"]
8-
9-
# Allows you to run this workflow manually from the Actions tab
4+
branches:
5+
- main
106
workflow_dispatch:
11-
12-
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
137
permissions:
148
contents: read
159
pages: write
1610
id-token: write
17-
18-
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
19-
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
2011
concurrency:
21-
group: "pages"
12+
group: pages
2213
cancel-in-progress: false
23-
24-
# Default to bash
2514
defaults:
2615
run:
2716
shell: bash
28-
2917
jobs:
30-
# Build job
3118
build:
3219
runs-on: ubuntu-latest
3320
env:
34-
HUGO_VERSION: 0.148.0
21+
DART_SASS_VERSION: 1.93.2
22+
GO_VERSION: 1.25.1
23+
HUGO_VERSION: 0.151.0
24+
NODE_VERSION: 22.18.0
25+
TZ: Europe/Oslo
3526
steps:
36-
- name: Install Hugo CLI
37-
run: |
38-
wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \
39-
&& sudo dpkg -i ${{ runner.temp }}/hugo.deb
40-
- name: Install Dart Sass
41-
run: sudo snap install dart-sass
4227
- name: Checkout
43-
uses: actions/checkout@v4
28+
uses: actions/checkout@v5
4429
with:
4530
submodules: recursive
31+
fetch-depth: 0
32+
- name: Setup Go
33+
uses: actions/setup-go@v5
34+
with:
35+
go-version: ${{ env.GO_VERSION }}
36+
cache: false
37+
- name: Setup Node.js
38+
uses: actions/setup-node@v4
39+
with:
40+
node-version: ${{ env.NODE_VERSION }}
4641
- name: Setup Pages
4742
id: pages
4843
uses: actions/configure-pages@v5
49-
- name: Setup Node.js
50-
uses: actions/setup-node@v4
44+
- name: Create directory for user-specific executable files
45+
run: |
46+
mkdir -p "${HOME}/.local"
47+
- name: Install Dart Sass
48+
run: |
49+
curl -sLJO "https://github.com/sass/dart-sass/releases/download/${DART_SASS_VERSION}/dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz"
50+
tar -C "${HOME}/.local" -xf "dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz"
51+
rm "dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz"
52+
echo "${HOME}/.local/dart-sass" >> "${GITHUB_PATH}"
53+
- name: Install Hugo
54+
run: |
55+
curl -sLJO "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.tar.gz"
56+
mkdir "${HOME}/.local/hugo"
57+
tar -C "${HOME}/.local/hugo" -xf "hugo_extended_${HUGO_VERSION}_linux-amd64.tar.gz"
58+
rm "hugo_extended_${HUGO_VERSION}_linux-amd64.tar.gz"
59+
echo "${HOME}/.local/hugo" >> "${GITHUB_PATH}"
60+
- name: Verify installations
61+
run: |
62+
echo "Dart Sass: $(sass --version)"
63+
echo "Go: $(go version)"
64+
echo "Hugo: $(hugo version)"
65+
echo "Node.js: $(node --version)"
66+
- name: Install Node.js dependencies
67+
run: |
68+
[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true
69+
- name: Configure Git
70+
run: |
71+
git config core.quotepath false
72+
- name: Cache restore
73+
id: cache-restore
74+
uses: actions/cache/restore@v4
75+
with:
76+
path: ${{ runner.temp }}/hugo_cache
77+
key: hugo-${{ github.run_id }}
78+
restore-keys:
79+
hugo-
80+
- name: Build the site
81+
run: |
82+
hugo \
83+
--gc \
84+
--minify \
85+
--baseURL "${{ steps.pages.outputs.base_url }}/" \
86+
--cacheDir "${{ runner.temp }}/hugo_cache"
87+
- name: Cache save
88+
id: cache-save
89+
uses: actions/cache/save@v4
5190
with:
52-
node-version: '20'
53-
cache: 'npm'
54-
- name: Install dependencies
55-
run: npm ci
56-
- name: Build with npm
57-
env:
58-
HUGO_CACHEDIR: ${{ runner.temp }}/hugo_cache
59-
HUGO_ENVIRONMENT: production
60-
HUGO_BASEURL: ${{ steps.pages.outputs.base_url }}/
61-
run: npm run build
91+
path: ${{ runner.temp }}/hugo_cache
92+
key: ${{ steps.cache-restore.outputs.cache-primary-key }}
6293
- name: Upload artifact
6394
uses: actions/upload-pages-artifact@v3
6495
with:
65-
path: ./exampleSite/public
66-
67-
# Deployment job
96+
path: ./public
6897
deploy:
6998
environment:
7099
name: github-pages

0 commit comments

Comments
 (0)