Skip to content

Commit 64cc706

Browse files
committed
GitHub Action
1 parent dca6d46 commit 64cc706

1 file changed

Lines changed: 83 additions & 0 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Deploy Hugo site to GitHub Pages
2+
3+
on:
4+
# Trigger the workflow on push to main branch
5+
push:
6+
branches:
7+
- main
8+
9+
# Allow manual trigger from the Actions tab
10+
workflow_dispatch:
11+
12+
# Set GITHUB_TOKEN permissions to allow deployment to GitHub Pages
13+
permissions:
14+
contents: read
15+
pages: write
16+
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.
20+
concurrency:
21+
group: "pages"
22+
cancel-in-progress: false
23+
24+
# Default to bash
25+
defaults:
26+
run:
27+
shell: bash
28+
29+
jobs:
30+
# Build job
31+
build:
32+
runs-on: ubuntu-latest
33+
env:
34+
HUGO_VERSION: 0.151.2
35+
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+
41+
- name: Install Dart Sass
42+
run: sudo snap install dart-sass
43+
44+
- name: Checkout
45+
uses: actions/checkout@v4
46+
with:
47+
submodules: recursive
48+
fetch-depth: 0
49+
50+
- name: Setup Pages
51+
id: pages
52+
uses: actions/configure-pages@v5
53+
54+
- name: Install Node.js dependencies
55+
run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true"
56+
57+
- name: Build with Hugo
58+
env:
59+
# For maximum backward compatibility with Hugo modules
60+
HUGO_ENVIRONMENT: production
61+
HUGO_ENV: production
62+
run: |
63+
hugo \
64+
--gc \
65+
--minify \
66+
--baseURL "${{ steps.pages.outputs.base_url }}/"
67+
68+
- name: Upload artifact
69+
uses: actions/upload-pages-artifact@v3
70+
with:
71+
path: ./public
72+
73+
# Deployment job
74+
deploy:
75+
environment:
76+
name: github-pages
77+
url: ${{ steps.deployment.outputs.page_url }}
78+
runs-on: ubuntu-latest
79+
needs: build
80+
steps:
81+
- name: Deploy to GitHub Pages
82+
id: deployment
83+
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)