Skip to content

Commit c91f0b2

Browse files
committed
update action
1 parent c4d77e6 commit c91f0b2

File tree

2 files changed

+84
-29
lines changed

2 files changed

+84
-29
lines changed

.github/workflows/gh-page.yml

Lines changed: 80 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,98 @@
1-
name: GitHub Pages
1+
# Sample workflow for building and deploying a Hugo site to GitHub Pages
2+
name: Deploy Hugo site to Pages
23

34
on:
5+
# Runs on pushes targeting the default branch
46
push:
57
branches:
68
- master
7-
pull_request:
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
829

930
jobs:
10-
pages:
11-
name: Deploy to GitHub Pages
31+
# Build job
32+
build:
1233
runs-on: ubuntu-latest
34+
env:
35+
HUGO_VERSION: 0.147.2
36+
HUGO_ENVIRONMENT: production
37+
TZ: America/Los_Angeles
1338
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
1445
- name: Checkout
1546
uses: actions/checkout@v4
1647
with:
17-
submodules: true
48+
submodules: recursive
1849
fetch-depth: 0
19-
20-
- name: Setup Hugo
21-
uses: peaceiris/actions-hugo@v3
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
2258
with:
23-
hugo-version: "latest"
24-
extended: true
25-
26-
- name: Clean public
27-
working-directory: exampleSite
28-
run: rm -rf ./public/*
59+
path: |
60+
${{ runner.temp }}/hugo_cache
61+
key: hugo-${{ github.run_id }}
62+
restore-keys:
63+
hugo-
64+
- name: Configure Git
65+
run: git config core.quotepath false
2966

30-
- name: Build
67+
- name: Build with Hugo
3168
working-directory: exampleSite
32-
run: hugo --themesDir=../.. --minify --environment production -b https://ntk148v.github.io/shibui
33-
34-
- name: Deploy
35-
uses: peaceiris/actions-gh-pages@v3
36-
if: ${{ github.ref == 'refs/heads/master' }}
69+
run: |
70+
hugo \
71+
--themesDir=../.. \
72+
--gc \
73+
--minify \
74+
--baseURL "${{ steps.pages.outputs.base_url }}/" \
75+
--cacheDir "${{ runner.temp }}/hugo_cache"
76+
- name: Cache Save
77+
id: cache-save
78+
uses: actions/cache/save@v4
3779
with:
38-
github_token: ${{ secrets.GITHUB_TOKEN }}
39-
publish_branch: gh-pages
40-
publish_dir: ./exampleSite/public
41-
42-
- name: Setup hugo cache
43-
uses: actions/cache@v4
80+
path: |
81+
${{ runner.temp }}/hugo_cache
82+
key: ${{ steps.cache-restore.outputs.cache-primary-key }}
83+
- name: Upload artifact
84+
uses: actions/upload-pages-artifact@v3
4485
with:
45-
path: ./exampleSite/resources
46-
key: ${{ runner.os }}-hugo-${{ hashFiles('./exampleSite/resources') }}
47-
restore-keys: ${{ runner.os }}-hugo-
86+
path: ./public
87+
88+
# Deployment job
89+
deploy:
90+
environment:
91+
name: github-pages
92+
url: ${{ steps.deployment.outputs.page_url }}
93+
runs-on: ubuntu-latest
94+
needs: build
95+
steps:
96+
- name: Deploy to GitHub Pages
97+
id: deployment
98+
uses: actions/deploy-pages@v4

exampleSite/config.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,7 @@ email = "kiennt2609@gmail.com"
4545
expiryDate = ['expiryDate']
4646
lastmod = [':git', 'lastmod', 'date', 'publishDate']
4747
publishDate = ['publishDate', 'date']
48+
49+
[caches]
50+
[caches.images]
51+
dir = ':cacheDir/images'

0 commit comments

Comments
 (0)