blob: a259c2a24e832d28038a32cb7621b1dc49013592 (
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
|
#!/bin/sh
# Optional: auto-deploy when pushing to a bare repo on the host.
#
# The normal workflow is scripts/deploy.sh from the development machine; this
# hook is for the variant where the host also has the toolchain and a working
# checkout. Install as hooks/post-receive in the bare repo, make it
# executable, and set WORK_TREE to a checkout whose origin is that bare repo.
set -eu
WORK_TREE="${WORK_TREE:-/srv/bokf/src}"
DEPLOY_DIR="${DEPLOY_DIR:-/srv/bokf}"
BRANCH="${BRANCH:-refs/heads/main}"
while read -r _old _new ref; do
[ "$ref" = "$BRANCH" ] || continue
cd "$WORK_TREE"
git pull --ff-only
make -j"$(nproc)"
make test
tag="$(git describe --tags --always)"
docker build -t "bokf:$tag" .
cp compose.yaml "$DEPLOY_DIR/compose.yaml"
touch "$DEPLOY_DIR/.env"
sed -i '/^BOKF_IMAGE=/d;/^BOKF_TAG=/d' "$DEPLOY_DIR/.env"
printf 'BOKF_IMAGE=bokf\nBOKF_TAG=%s\n' "$tag" >> "$DEPLOY_DIR/.env"
cd "$DEPLOY_DIR"
docker compose up -d --no-build
docker compose ps
done
|