1
+ # Sample workflow for building and deploying a Hugo site to GitHub Pages
2
+ name : Deploy Hugo site to Pages
3
+
4
+ on :
5
+ # Runs on pushes targeting the default branch
6
+ push :
7
+ branches :
8
+ - main
9
+
10
+ # Allows you to run this workflow manually from the Actions tab
11
+ workflow_dispatch :
12
+
13
+ # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
14
+ permissions :
15
+ contents : read
16
+ pages : write
17
+ id-token : write
18
+
19
+ # Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
20
+ # However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
21
+ concurrency :
22
+ group : " pages"
23
+ cancel-in-progress : false
24
+
25
+ # Default to bash
26
+ defaults :
27
+ run :
28
+ shell : bash
29
+
30
+ jobs :
31
+ # Build job
32
+ build :
33
+ runs-on : ubuntu-latest
34
+ env :
35
+ HUGO_VERSION : 0.145.0
36
+ HUGO_ENVIRONMENT : production
37
+ steps :
38
+ - name : Install Hugo CLI
39
+ run : |
40
+ wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \
41
+ && sudo dpkg -i ${{ runner.temp }}/hugo.deb
42
+ - name : Install Dart Sass
43
+ run : sudo snap install dart-sass
44
+ - name : Checkout
45
+ uses : actions/checkout@v4
46
+ with :
47
+ submodules : recursive
48
+ fetch-depth : 0
49
+ - name : Setup Pages
50
+ id : pages
51
+ uses : actions/configure-pages@v5
52
+ - name : Install Node.js dependencies
53
+ run : " [[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true"
54
+ - name : Cache Restore
55
+ id : cache-restore
56
+ uses : actions/cache/restore@v4
57
+ with :
58
+ path : |
59
+ ${{ runner.temp }}/hugo_cache
60
+ key : hugo-${{ github.run_id }}
61
+ restore-keys :
62
+ hugo-
63
+ - name : Build with Hugo
64
+ run : |
65
+ hugo \
66
+ --gc \
67
+ --minify \
68
+ --baseURL "${{ steps.pages.outputs.base_url }}/" \
69
+ --cacheDir "${{ runner.temp }}/hugo_cache"
70
+ - name : Cache Save
71
+ id : cache-save
72
+ uses : actions/cache/save@v4
73
+ with :
74
+ path : |
75
+ ${{ runner.temp }}/hugo_cache
76
+ key : ${{ steps.cache-restore.outputs.cache-primary-key }}
77
+ - name : Upload artifact
78
+ uses : actions/upload-pages-artifact@v3
79
+ with :
80
+ path : ./public
81
+
82
+ # Deployment job
83
+ deploy :
84
+ environment :
85
+ name : github-pages
86
+ url : ${{ steps.deployment.outputs.page_url }}
87
+ runs-on : ubuntu-latest
88
+ needs : build
89
+ steps :
90
+ - name : Deploy to GitHub Pages
91
+ id : deployment
92
+ uses : actions/deploy-pages@v4
0 commit comments