Skip to content

Commit 253b6c7

Browse files
committed
Added Github Actions
- Added workflow to deploy Hugo to Github Pages.
1 parent 293b3f5 commit 253b6c7

File tree

2 files changed

+97
-0
lines changed

2 files changed

+97
-0
lines changed

.github/workflows/hugo.yaml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Sample workflow for building and deploying a Hugo site to GitHub Pages
2+
name: Deploy Hugo site to Github 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+
TZ: America/New_York
38+
steps:
39+
- name: Install Hugo CLI
40+
run: |
41+
wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \
42+
&& sudo dpkg -i ${{ runner.temp }}/hugo.deb
43+
- name: Install Dart Sass
44+
run: sudo snap install dart-sass
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: "[[ -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+
--baseURL "${{ steps.pages.outputs.base_url }}/" \
70+
--cacheDir "${{ runner.temp }}/hugo_cache"
71+
- name: Cache Save
72+
id: cache-save
73+
uses: actions/cache/save@v4
74+
with:
75+
path: |
76+
${{ runner.temp }}/hugo_cache
77+
key: ${{ steps.cache-restore.outputs.cache-primary-key }}
78+
- name: Upload artifact
79+
uses: actions/upload-pages-artifact@v3
80+
with:
81+
path: ./public
82+
83+
# Deployment job
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

hugo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ Name = "Bobby"
7272
url = "/tags/"
7373
weight = 40
7474

75+
[caches]
76+
[caches.images]
77+
dir = ':cacheDir/images'
78+
7579
[taxonomies]
7680
category = "categories"
7781
tag = "tags"

0 commit comments

Comments
 (0)