File tree Expand file tree Collapse file tree 1 file changed +14
-6
lines changed Expand file tree Collapse file tree 1 file changed +14
-6
lines changed Original file line number Diff line number Diff line change 1
- # Sample workflow for building and deploying a Hugo site to GitHub Pages
2
1
name : Deploy Hugo site to Pages
3
2
4
3
on :
5
- # Runs on pushes targeting the default branch
6
4
push :
7
5
branches : ["main"]
8
6
9
- # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
10
7
permissions :
11
8
contents : read
12
9
pages : write
13
10
id-token : write
14
11
15
- # Environment variables available to all jobs and steps in this workflow
16
12
env :
17
13
HUGO_ENV : production
18
14
HUGO_VERSION : " 0.118.2"
19
15
GO_VERSION : " 1.20.5"
20
16
NODE_VERSION : " 18.15.0"
21
17
22
18
jobs :
23
- # Build job
24
19
build :
25
20
runs-on : ubuntu-24.04-arm
26
21
steps :
50
45
- name : Install npm dependencies
51
46
run : npm install
52
47
48
+ - name : Determine Base URL
49
+ id : base_url
50
+ run : |
51
+ REPO_NAME=$(echo "${{ github.repository }}" | cut -d '/' -f 2)
52
+ if [[ "${{ github.repository_owner }}" == "${{ github.repository_owner }}" ]]; then
53
+ BASE_URL="https://${{ github.repository_owner }}.github.io/${REPO_NAME}/"
54
+ else
55
+ BASE_URL="https://${{ github.repository_owner }}.github.io/"
56
+ fi
57
+ echo "BASE_URL=$BASE_URL" >> $GITHUB_ENV
58
+
59
+ - name : Modify hugo.toml
60
+ run : sed -i "s|baseURL = .*|baseURL = \"$BASE_URL\"|" hugo.toml
61
+
53
62
- name : Build site
54
63
run : npm run build
55
64
58
67
with :
59
68
path : ./public
60
69
61
- # Deployment job
62
70
deploy :
63
71
environment :
64
72
name : github-pages
You can’t perform that action at this time.
0 commit comments