-
Notifications
You must be signed in to change notification settings - Fork 0
107 lines (89 loc) · 3.25 KB
/
hugo.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
name: Deploy Hugo site to Pages
on:
push:
branches:
- main
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: "pages"
cancel-in-progress: false
defaults:
run:
shell: bash
jobs:
build:
runs-on: ubuntu-latest
#env:
#HUGO_VERSION: v0.131.0
steps:
- name: Get Latest Hugo Version
if: ${{ env.HUGO_VERSION == '' }}
run: |
HUGO_VERSION=$(curl -s https://api.github.com/repos/gohugoio/hugo/releases/latest | jq -r '.tag_name')
echo "HUGO_VERSION=$HUGO_VERSION" >> $GITHUB_ENV
echo "Latest Hugo version: ${HUGO_VERSION}"
- name: Create Hugo Directory
id: hugo-dir
continue-on-error: true
run: |
target_dir="${{ runner.tool_cache }}/hugo"
echo "target_dir=${target_dir}" >> $GITHUB_OUTPUT
mkdir -p "${target_dir}"
- name: Cache Hugo
id: cache-hugo
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
with:
path: ${{ runner.tool_cache }}/hugo/hugo
key: ${{ runner.os }}-${{ env.HUGO_VERSION }}-hugo
- name: Install Hugo CLI
if: steps.cache-hugo.outputs.cache-hit != 'true'
run: |
declare -A oses=( ["Linux"]="linux" ["macOS"]="darwin" )
_os="${oses[$RUNNER_OS]}"
declare -A arches=( ["X64"]="amd64" ["ARM"]="arm64" ["ARM64"]="arm64" )
_arch="${arches[$RUNNER_ARCH]}"
output_file="${{ runner.temp }}/hugo.tar.gz"
wget -O ${output_file} https://github.com/gohugoio/hugo/releases/download/${HUGO_VERSION}/hugo_extended_${HUGO_VERSION#v}_${_os}-${_arch}.tar.gz
tar -C "${{ runner.temp }}" -xzf "${output_file}"
mv "${{ runner.temp }}/hugo" "${{ steps.hugo-dir.outputs.target_dir }}"
- name: Add Hugo to PATH
run: echo "${{ runner.tool_cache }}/hugo" >> $GITHUB_PATH
- name: Install Dart Sass
run: sudo snap install dart-sass
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
submodules: recursive
- name: Setup Pages
id: pages
uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5.0.0
- name: Install Node.js dependencies
run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true"
- name: Build with Hugo
env:
# For maximum backward compatibility with Hugo modules
HUGO_ENVIRONMENT: production
HUGO_ENV: production
run: |
hugo \
--gc \
--minify \
--baseURL "${{ steps.pages.outputs.base_url }}/"
- name: Upload artifact
uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3.0.1
with:
path: ./public
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5