blob: 1a08fc5380fc6d3cb3ef8c2d3a4c37f1795e9f27 (
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
58
59
60
61
62
63
64
|
#!/bin/bash
# deploy — Build and deploy claudomator to /site/doot.terst.org
# Usage: ./scripts/deploy [--dirty]
# Example: sudo ./scripts/deploy
set -euo pipefail
DIRTY=false
for arg in "$@"; do
if [ "$arg" == "--dirty" ]; then
DIRTY=true
fi
done
FQDN="doot.terst.org"
SITE_DIR="/site/${FQDN}"
BIN_DIR="${SITE_DIR}/bin"
SERVICE="claudomator@${FQDN}.service"
REPO_DIR="$(cd "$(dirname "$0")/.." && pwd)"
cd "${REPO_DIR}"
echo "==> Pulling latest from bare repo..."
git pull --ff-only local main
STASHED=false
if [ "$DIRTY" = false ] && [ -n "$(git status --porcelain)" ]; then
echo "==> Stashing uncommitted changes..."
git stash push -u -m "Auto-stash before deploy"
STASHED=true
trap 'if [ "$STASHED" = true ]; then echo "==> Popping stash..."; git stash pop; fi' EXIT
fi
echo "==> Verifying (build + tests)..."
"${REPO_DIR}/scripts/verify"
echo "==> Building claudomator..."
export GOCACHE="${SITE_DIR}/cache/go-build"
export GOPATH="${SITE_DIR}/cache/gopath"
mkdir -p "${GOCACHE}" "${GOPATH}"
go build -o "${BIN_DIR}/claudomator" ./cmd/claudomator/
echo "==> Copying scripts..."
mkdir -p "${SITE_DIR}/scripts"
find "${REPO_DIR}/scripts" -maxdepth 1 -type f -exec cp -p {} "${SITE_DIR}/scripts/" \;
echo "==> Installing to /usr/local/bin..."
cp "${BIN_DIR}/claudomator" /usr/local/bin/claudomator
echo "==> Fixing permissions..."
"${REPO_DIR}/scripts/fix-permissions"
echo "==> Syncing credentials..."
"${REPO_DIR}/scripts/sync-credentials"
echo "==> Ensuring binary and scripts are executable..."
chmod +x "${BIN_DIR}/claudomator" /usr/local/bin/claudomator
find "${SITE_DIR}/scripts" -maxdepth 1 -type f -exec chmod +x {} +
echo "==> Restarting service..."
sudo systemctl restart "${SERVICE}"
sudo systemctl status "${SERVICE}" --no-pager -l
echo "==> Done!"
|