Skip to content

Commit bada00c

Browse files
committed
github workflow hugo
1 parent f03a978 commit bada00c

1 file changed

Lines changed: 96 additions & 0 deletions

File tree

.github/workflows/hugo.yaml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# Hugo's official workflow for GitHub Pages
2+
# https://gohugo.io/host-and-deploy/host-on-github-pages/
3+
# In repo Settings > Pages > Build and deployment: set Source to "GitHub Actions"
4+
5+
name: Build and deploy
6+
7+
on:
8+
push:
9+
branches: [master]
10+
workflow_dispatch:
11+
12+
permissions:
13+
contents: read
14+
pages: write
15+
id-token: write
16+
17+
concurrency:
18+
group: pages
19+
cancel-in-progress: false
20+
21+
defaults:
22+
run:
23+
shell: bash
24+
25+
jobs:
26+
build:
27+
runs-on: ubuntu-latest
28+
env:
29+
HUGO_VERSION: 0.155.0
30+
TZ: Europe/Oslo
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@v6
34+
with:
35+
submodules: recursive
36+
fetch-depth: 0
37+
38+
- name: Setup Pages
39+
id: pages
40+
uses: actions/configure-pages@v5
41+
42+
- name: Create directory for user-specific executable files
43+
run: mkdir -p "${HOME}/.local"
44+
45+
- name: Install Hugo
46+
run: |
47+
curl -sLJO "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.tar.gz"
48+
mkdir "${HOME}/.local/hugo"
49+
tar -C "${HOME}/.local/hugo" -xf "hugo_extended_${HUGO_VERSION}_linux-amd64.tar.gz"
50+
rm "hugo_extended_${HUGO_VERSION}_linux-amd64.tar.gz"
51+
echo "${HOME}/.local/hugo" >> "${GITHUB_PATH}"
52+
53+
- name: Verify Hugo
54+
run: hugo version
55+
56+
- name: Configure Git
57+
run: git config core.quotepath false
58+
59+
- name: Cache restore
60+
id: cache-restore
61+
uses: actions/cache/restore@v5
62+
with:
63+
path: ${{ runner.temp }}/hugo_cache
64+
key: hugo-${{ github.run_id }}
65+
restore-keys: hugo-
66+
67+
- name: Build the site
68+
run: |
69+
hugo \
70+
--gc \
71+
--minify \
72+
--baseURL "${{ steps.pages.outputs.base_url }}/" \
73+
--cacheDir "${{ runner.temp }}/hugo_cache"
74+
75+
- name: Cache save
76+
id: cache-save
77+
uses: actions/cache/save@v5
78+
with:
79+
path: ${{ runner.temp }}/hugo_cache
80+
key: ${{ steps.cache-restore.outputs.cache-primary-key }}
81+
82+
- name: Upload artifact
83+
uses: actions/upload-pages-artifact@v3
84+
with:
85+
path: ./public
86+
87+
deploy:
88+
environment:
89+
name: github-pages
90+
url: ${{ steps.deployment.outputs.page_url }}
91+
runs-on: ubuntu-latest
92+
needs: build
93+
steps:
94+
- name: Deploy to GitHub Pages
95+
id: deployment
96+
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)