Skip to content

Commit f225ec9

Browse files
Improved deployment workflow (following suggested example)
1 parent 24ce438 commit f225ec9

File tree

1 file changed

+47
-21
lines changed

1 file changed

+47
-21
lines changed

.github/workflows/hugo.yaml

Lines changed: 47 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ name: Deploy website
22

33
on:
44
push:
5-
branches:
6-
- main
5+
branches: ["main"]
76

87
workflow_dispatch:
98

@@ -12,28 +11,55 @@ permissions:
1211
pages: write
1312
id-token: write
1413

14+
concurrency:
15+
group: "pages"
16+
cancel-in-progress: false
17+
18+
defaults:
19+
run:
20+
shell: bash
21+
1522
jobs:
16-
deploy:
23+
build:
1724
runs-on: ubuntu-latest
18-
concurrency:
19-
group: ${{ github.workflow }}-${{ github.ref }}
25+
env:
26+
HUGO_VERSION: 0.128.0
2027
steps:
21-
- uses: actions/checkout@v4
28+
- name: Install Hugo CLI
29+
run: |
30+
wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \
31+
&& sudo dpkg -i ${{ runner.temp }}/hugo.deb
32+
- name: Install Dart Sass
33+
run: sudo snap install dart-sass
34+
- name: Checkout
35+
uses: actions/checkout@v4
2236
with:
23-
submodules: true
24-
fetch-depth: 0
25-
26-
- name: Setup Hugo
27-
uses: peaceiris/actions-hugo@v3
37+
submodules: recursive
38+
- name: Setup Pages
39+
id: pages
40+
uses: actions/configure-pages@v5
41+
- name: Install Node.js dependencies
42+
run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true"
43+
- name: Build with Hugo
44+
env:
45+
HUGO_CACHEDIR: ${{ runner.temp }}/hugo_cache
46+
HUGO_ENVIRONMENT: production
47+
run: |
48+
hugo \
49+
--minify \
50+
--baseURL "${{ steps.pages.outputs.base_url }}/"
51+
- name: Upload artifact
52+
uses: actions/upload-pages-artifact@v3
2853
with:
29-
hugo-version: 'latest'
30-
31-
- name: Build
32-
run: hugo --minify
54+
path: ./public
3355

34-
- name: Deploy
35-
uses: peaceiris/actions-gh-pages@v3
36-
if: github.ref == 'refs/heads/main'
37-
with:
38-
github_token: ${{ secrets.GITHUB_TOKEN }}
39-
publish_dir: ./public
56+
deploy:
57+
environment:
58+
name: github-pages
59+
url: ${{ steps.deployment.outputs.page_url }}
60+
runs-on: ubuntu-latest
61+
needs: build
62+
steps:
63+
- name: Deploy to GitHub Pages
64+
id: deployment
65+
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)