-
Notifications
You must be signed in to change notification settings - Fork 0
81 lines (69 loc) · 2.86 KB
/
hugo-init.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
name: Hugo - Initialize
# Original source: htts://github.com/boochtek/hugo-init
# Original author: Craig Buchek (@booch).
on:
# Run manually from the Actions tab.
workflow_dispatch:
title:
description: "Title of the site"
required: true
type: string
language_code:
description: "ISO Language Code for the site"
type: string
default: "en-us"
# Set permissions of the GITHUB_TOKEN to allow pushing.
permissions:
contents: write
defaults:
run:
shell: bash
jobs:
hugo-init:
runs-on: ubuntu-latest
steps:
- name: Install Hugo CLI
run: |
HUGO_LATEST_RELEASE_JSON=$(curl -s https://api.github.com/repos/gohugoio/hugo/releases/latest)
HUGO_VERSION=$(echo $HUGO_LATEST_RELEASE_JSON | tr -cd '[:print:]' | jq -r '.tag_name' | cut -c2-)
HUGO_DEB_URL="https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb"
wget -O "${{ runner.temp }}/hugo.deb" "$HUGO_DEB_URL" \
&& sudo dpkg -i ${{ runner.temp }}/hugo.deb
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Make sure we don't already have a Hugo config
run: |
[[ ! -f hugo.toml && ! -f hugo.yaml && ! -f hugo.json && ! -d config ]]
- name: Initalize Hugo
run: |
hugo new site . --force
- name: Make sure any new empty directories get committed
run: |
find . -type d -empty -not -regex '.*/\.git/.*' -exec touch '{}/.gitkeep' ';'
- name: Add base URL to Hugo config
run: |
CONFIG_FILE="hugo.toml"
CNAME="$(cat CNAME)"
if [[ -n "$CNAME" ]]; then
sed -i "s/^baseURL = \".*\"/baseURL = \"https://$CNAME/\"/" $CONFIG_FILE
fi
- name: Commit changes
uses: EndBug/add-and-commit@v9
with:
message: Add Hugo
hugo-next-steps:
runs-on: ubuntu-latest
steps:
- name: Print next steps
run: |
echo "1. Edit `hugo.toml` to configure your site."
echo "2. Add a theme - you can use the GitHub Action."
echo "3. Pull down the repo to your computer."
echo "4. Start the Hugo server:"
echo " hugo server -D"
echo "5. Open http://localhost:1313/ to see your new site."
echo "6. Add or update content. Commit changes to git."
echo "7. Push to publish to GitHub Pages via GitHub Action."