blob: 376e4b40e35b8efce9f127033e2f45147fe37c04 (
plain)
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
|
[tools]
caddy = "latest"
[tasks.gen]
run = "weft -gitignore . https://tjp.lol"
[tasks.clean]
description = "Remove Weft-generated outputs"
run = '''
if [ -f .weft-generated.json ]; then
jq -r '.outputs[]' .weft-generated.json | xargs -n 1 rm -f
else
awk '/^# BEGIN weft generated outputs$/ { generated = 1; next } /^# END weft generated outputs$/ { generated = 0 } generated { sub(/^\//, ""); print }' .gitignore | xargs -n 1 rm -f
fi
rm -f .weft-txn-*
'''
[tasks.dev]
description = "Run the auto-reloading dev server and open the site in a browser"
run = "(sleep 1 && open http://127.0.0.1:8001/) & exec air"
[tasks."deploy:weft"]
description = "Build and deploy weft to tjp.lol"
run = '''
set -euo pipefail
cd ../weft
env GOOS=freebsd GOARCH=amd64 go build -o weft-freebsd-amd64 .
trap 'rm weft-freebsd-amd64' EXIT
scp weft-freebsd-amd64 t@tjp.lol:weft
ssh t@tjp.lol "doas sh -c 'mv weft /jail/containers/code-push/usr/local/bin/weft && chown root:wheel /jail/containers/code-push/usr/local/bin/weft'"
'''
[tasks."deploy:site"]
description = "Push the current 'main' bookmark to deploy the site"
run = "jj git push -b main"
[tasks.deploy]
description = "Push the 'main' bookmark and update weft on the server"
run = "mise run deploy:weft && mise run deploy:site"
[tasks."upload:image"]
description = "Upload an image to the production server"
usage = '''
arg "file"
arg "path"
'''
run = '''
set -euo pipefail
fname=`basename $usage_file`
dirpath=`dirname $usage_path`
site_imgs=/jail/volumes/web/https/images
scp $usage_file t@tjp.lol:/tmp/$fname
ssh t@tjp.lol "doas sh -c 'mkdir -p ${site_imgs}/${dirpath} && mv /tmp/${fname} ${site_imgs}/${usage_path} && chown root:wheel ${site_imgs}/${usage_path}'"
'''
|