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