Skip to content

Commit 60558b8

Browse files
authored
feat(deploy): script.
This workflow automates the deployment of a Hugo site to GitHub Pages upon pushes to the main branch.
1 parent 3e63341 commit 60558b8

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

.github/workflows/deploy.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Deploy Hugo site to GitHub Pages
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
pages: write
11+
id-token: write
12+
13+
concurrency:
14+
group: "pages"
15+
cancel-in-progress: false
16+
17+
defaults:
18+
run:
19+
shell: bash
20+
21+
jobs:
22+
build:
23+
runs-on: ubuntu-latest
24+
env:
25+
HUGO_VERSION: 0.156.0
26+
steps:
27+
- name: Install Hugo CLI
28+
run: |
29+
wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \
30+
&& sudo dpkg -i ${{ runner.temp }}/hugo.deb
31+
32+
- name: Checkout
33+
uses: actions/checkout@v4
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: Build with Hugo
43+
env:
44+
HUGO_CACHEDIR: ${{ runner.temp }}/hugo_cache
45+
HUGO_ENVIRONMENT: production
46+
TZ: America/New_York
47+
run: |
48+
hugo \
49+
--gc \
50+
--minify \
51+
--baseURL "${{ steps.pages.outputs.base_url }}/"
52+
53+
- name: Upload artifact
54+
uses: actions/upload-pages-artifact@v3
55+
with:
56+
path: ./public
57+
58+
deploy:
59+
environment:
60+
name: github-pages
61+
url: ${{ steps.deployment.outputs.page_url }}
62+
runs-on: ubuntu-latest
63+
needs: build
64+
steps:
65+
- name: Deploy to GitHub Pages
66+
id: deployment
67+
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)