Skip to content

Commit 1e845a0

Browse files
authored
Update hugo-pages.yml (#82)
1 parent 1ae25fa commit 1e845a0

File tree

1 file changed

+35
-65
lines changed

1 file changed

+35
-65
lines changed

.github/workflows/hugo-pages.yml

Lines changed: 35 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,99 +1,69 @@
1-
name: Hugo Build and deploy
1+
# Sample workflow for building and deploying a Hugo site to GitHub Pages
2+
name: Deploy Hugo site to Pages
3+
24
on:
5+
# Runs on pushes targeting the default branch
36
push:
4-
branches:
5-
- main
7+
branches: ["main"]
8+
9+
# Allows you to run this workflow manually from the Actions tab
610
workflow_dispatch:
11+
12+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
713
permissions:
814
contents: read
915
pages: write
1016
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.
1120
concurrency:
12-
group: pages
21+
group: "pages"
1322
cancel-in-progress: false
23+
24+
# Default to bash
1425
defaults:
1526
run:
1627
shell: bash
28+
1729
jobs:
30+
# Build job
1831
build:
1932
runs-on: ubuntu-latest
2033
env:
21-
DART_SASS_VERSION: 1.93.2
22-
GO_VERSION: 1.25.1
2334
HUGO_VERSION: 0.151.0
24-
NODE_VERSION: 22.18.0
25-
TZ: Europe/Oslo
2635
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
2742
- name: Checkout
28-
uses: actions/checkout@v5
43+
uses: actions/checkout@v4
2944
with:
3045
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 }}
4146
- name: Setup Pages
4247
id: pages
4348
uses: actions/configure-pages@v5
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)"
6649
- 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
50+
working-directory: ./exampleSite
51+
run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true"
52+
- name: Build with Hugo
53+
working-directory: ./exampleSite
54+
env:
55+
HUGO_CACHEDIR: ${{ runner.temp }}/hugo_cache
56+
HUGO_ENVIRONMENT: production
8157
run: |
8258
hugo \
83-
--gc \
8459
--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
90-
with:
91-
path: ${{ runner.temp }}/hugo_cache
92-
key: ${{ steps.cache-restore.outputs.cache-primary-key }}
60+
--baseURL "${{ steps.pages.outputs.base_url }}/"
9361
- name: Upload artifact
9462
uses: actions/upload-pages-artifact@v3
9563
with:
96-
path: ./public
64+
path: ./exampleSite/public
65+
66+
# Deployment job
9767
deploy:
9868
environment:
9969
name: github-pages

0 commit comments

Comments
 (0)