Repository navigation
Expand file tree
/
Copy pathTaskfile.yml
More file actions
203 lines (180 loc) · 5.86 KB
/
Copy pathTaskfile.yml
File metadata and controls
203 lines (180 loc) · 5.86 KB
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
version: "3"
vars:
HUGO_IMAGE: hugomods/hugo:exts-0.154.3
NODE_IMAGE: node:lts
NGINX_IMAGE: nginx:alpine
PYTHON_IMAGE: python:3-alpine
AWS_IMAGE: amazon/aws-cli:latest
THEME_DIR: hugo/themes/frobiovox-theme
BUCKET: www.frobiovox.com
NETWORK: frobiovox-net
DEV_CONTAINER: frobiovox-site-dev
PREVIEW_CONTAINER: frobiovox-site-preview
PREVIEW_PORT: 8088
UID:
sh: id -u
GID:
sh: id -g
# Repo root is mounted at /src; Hugo runs from /src/hugo because hugo.toml
# points contentDir at ../content.
HUGO_RUN: >-
docker run --rm
-u {{.UID}}:{{.GID}}
-e HUGO_CACHEDIR=/tmp/hugo_cache
-v {{.ROOT_DIR}}:/src
-w /src/hugo
{{.HUGO_IMAGE}}
tasks:
default:
desc: List all available tasks
cmds:
- task --list
deps:theme:
desc: Install the theme's Node dependencies (Tailwind, Vite, mermaid)
cmds:
- >-
docker run --rm -u {{.UID}}:{{.GID}}
-v {{.ROOT_DIR}}/{{.THEME_DIR}}:/app -w /app
{{.NODE_IMAGE}} npm install
status:
- test -x {{.THEME_DIR}}/node_modules/.bin/vite
deps:all:
desc: Install every dependency the build needs
cmds:
- task: deps:theme
build:css:
desc: Build the theme's CSS and JS bundles with Vite
deps: [deps:theme]
cmds:
- >-
docker run --rm -u {{.UID}}:{{.GID}}
-v {{.ROOT_DIR}}/{{.THEME_DIR}}:/app -w /app
{{.NODE_IMAGE}} npx vite build
build:site:
desc: Build the site to hugo/public
cmds:
- "{{.HUGO_RUN}} hugo --cleanDestinationDir"
build:drafts:
desc: Build the site including drafts and future-dated posts
cmds:
- "{{.HUGO_RUN}} hugo --cleanDestinationDir --buildDrafts --buildFuture"
build:prod:
desc: Build the site for production (minified)
cmds:
- "{{.HUGO_RUN}} hugo --cleanDestinationDir --minify"
build:all:
desc: Build theme assets and the production site
cmds:
- task: build:css
- task: build:prod
test:rss:
desc: Validate the production RSS feeds (well-formed, required elements, dates)
deps: [build:prod]
cmds:
- >-
docker run --rm -u {{.UID}}:{{.GID}}
-v {{.ROOT_DIR}}:/src -w /src
{{.PYTHON_IMAGE}} python3 scripts/validate_rss.py hugo/public
test:all:
desc: Run every check against the built site
cmds:
- task: test:rss
new:post:
desc: Create a new post (usage - task new:post TITLE="My post title")
cmds:
- ./_tasks/post.sh {{.TITLE}}
requires:
vars: [TITLE]
start:server:
desc: Start the Hugo dev server on :1313 (detached)
cmds:
- docker network create {{.NETWORK}} 2>/dev/null || true
- >-
docker run --rm -d --name {{.DEV_CONTAINER}} --network {{.NETWORK}}
-p 1313:1313
-u {{.UID}}:{{.GID}}
-e HUGO_CACHEDIR=/tmp/hugo_cache
-v {{.ROOT_DIR}}:/src -w /src/hugo
{{.HUGO_IMAGE}}
hugo server --bind 0.0.0.0 --baseURL http://localhost:1313/ --appendPort=false
- echo "Dev server on http://localhost:1313 — 'task logs:server' to follow output"
start:drafts:
desc: Start the Hugo dev server on :1313 with drafts and future posts visible
cmds:
- docker network create {{.NETWORK}} 2>/dev/null || true
- >-
docker run --rm -d --name {{.DEV_CONTAINER}} --network {{.NETWORK}}
-p 1313:1313
-u {{.UID}}:{{.GID}}
-e HUGO_CACHEDIR=/tmp/hugo_cache
-v {{.ROOT_DIR}}:/src -w /src/hugo
{{.HUGO_IMAGE}}
hugo server --bind 0.0.0.0 --baseURL http://localhost:1313/ --appendPort=false
--buildDrafts --buildFuture
- echo "Dev server (drafts) on http://localhost:1313"
stop:server:
desc: Stop the Hugo dev server
cmds:
- docker stop {{.DEV_CONTAINER}} || true
start:preview:
desc: Serve the built hugo/public with nginx on :8088
deps: [build:site]
cmds:
- docker network create {{.NETWORK}} 2>/dev/null || true
- >-
docker run --rm -d --name {{.PREVIEW_CONTAINER}} --network {{.NETWORK}}
-p {{.PREVIEW_PORT}}:80
-v {{.ROOT_DIR}}/hugo/public:/usr/share/nginx/html:ro
{{.NGINX_IMAGE}}
- echo "Preview on http://localhost:{{.PREVIEW_PORT}}"
stop:preview:
desc: Stop the nginx preview server
cmds:
- docker stop {{.PREVIEW_CONTAINER}} || true
logs:server:
desc: Follow the Hugo dev server output
cmds:
- docker logs -f {{.DEV_CONTAINER}}
deploy:site:
desc: Build and deploy to S3, backing up the current bucket first
vars:
TIMESTAMP:
sh: date +%Y%m%d_%H%M%S
cmds:
- task: build:css
- task: test:rss
- >-
docker run --rm -u {{.UID}}:{{.GID}}
--env-file {{.ROOT_DIR}}/.env
-v {{.ROOT_DIR}}:/src -e HOME=/tmp -w /src
{{.AWS_IMAGE}}
s3 sync s3://{{.BUCKET}}/ backups/{{.TIMESTAMP}}/
- >-
docker run --rm -u {{.UID}}:{{.GID}}
--env-file {{.ROOT_DIR}}/.env
-v {{.ROOT_DIR}}:/src -e HOME=/tmp -w /src
{{.AWS_IMAGE}}
s3 sync hugo/public/ s3://{{.BUCKET}}/ --delete
preconditions:
- sh: test -f {{.ROOT_DIR}}/.env
msg: "No .env file — copy .env.example to .env and fill in your AWS credentials."
clean:build:
desc: Remove the built site and Hugo's resource cache
cmds:
- rm -rf hugo/public hugo/resources
clean:deps:
desc: Remove the theme's installed Node modules
cmds:
- rm -rf {{.THEME_DIR}}/node_modules
clean:containers:
desc: Stop any running dev or preview containers and remove the network
cmds:
- docker stop {{.DEV_CONTAINER}} 2>/dev/null || true
- docker stop {{.PREVIEW_CONTAINER}} 2>/dev/null || true
- docker network rm {{.NETWORK}} 2>/dev/null || true
clean:all:
desc: Remove build output, dependencies, and running containers
cmds:
- task: clean:containers
- task: clean:build
- task: clean:deps