#!/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