-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·72 lines (58 loc) · 1.5 KB
/
Copy pathdeploy.sh
File metadata and controls
executable file
·72 lines (58 loc) · 1.5 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
#!/usr/bin/env bash
set -euo pipefail
readonly HEALTH_STATE="$(git rev-parse --git-path deploy-health-ready)"
health() {
rm -f "$HEALTH_STATE"
pnpm wahoo:auth
pnpm health:all
git rev-parse HEAD > "$HEALTH_STATE"
}
require_health() {
if [[ ! -f "$HEALTH_STATE" ]]; then
echo "deploy blocked: run '$0 health' first" >&2
exit 1
fi
local health_revision
local current_revision
health_revision="$(<"$HEALTH_STATE")"
current_revision="$(git rev-parse HEAD)"
if [[ "$health_revision" != "$current_revision" ]]; then
echo "deploy blocked: repository changed since health ran; run '$0 health' again" >&2
exit 1
fi
}
load_env() {
if [[ ! -f .env ]]; then
echo "deploy blocked: .env is missing" >&2
exit 1
fi
set -a
source ./.env
set +a
}
deploy() {
require_health
load_env
git pull
require_health
git lfs install --local
git lfs pull
git lfs pull --include="quartz/runtime/native/packs/**"
git lfs checkout
export GITHUB_SHA="$(git rev-parse HEAD)"
EMAIL_EMITTER_ENABLED=1 NODE_ENV=production pnpm exec quartz/bootstrap-cli.mjs build --concurrency 16 --bundleInfo --verbose
fd --glob "*.ddl" public -x rm
fd --glob "*.war" public -x rm
rm public/embeddings-text.jsonl
pnpm model:retrain || echo "pace model refresh failed; deploying site without model update"
pnpm wrangler deploy --minify
rm -f "$HEALTH_STATE"
}
case "${1:-}" in
health) health ;;
"" | deploy) deploy ;;
*)
echo "usage: $0 [health|deploy]" >&2
exit 2
;;
esac