Files
errors.bitreport.pt/deploy/lxc/webhook-deploy.sh
T
1sonhador c02c300dc3 feat(deploy): version.json generation, webhook promote, verify (BIT-468)
Align LXC deploy with BIT-465: write-version-json.sh, optional
webhook-deploy.sh, verify.sh fails when ER_VERSION_JSON_PATH is set but
missing/invalid, env.example + nginx sketch + runbook updates.
Ignore deploy/lxc/runtime/ (generated on server).
2026-03-24 18:33:37 +00:00

46 lines
1.5 KiB
Bash
Executable File

#!/usr/bin/env bash
# Example promote script for Gitea webhook → LXC (BIT-465). Adjust branches, users, and
# restart policy for your host. Run as the user that owns the repo (often root on first setup).
set -euo pipefail
_ENV_FILE="/etc/error-reporting/env"
if [[ ! -f "${_ENV_FILE}" ]]; then
echo "webhook-deploy: missing ${_ENV_FILE}" >&2
exit 1
fi
set -a
# shellcheck disable=SC1090
source "${_ENV_FILE}"
set +a
_ROOT="${ER_REPO_ROOT:?ER_REPO_ROOT must be set in ${_ENV_FILE}}"
cd "${_ROOT}"
# Match your deploy branch (repository uses master today).
_DEPLOY_BRANCH="${ER_DEPLOY_BRANCH:-master}"
git fetch origin "${_DEPLOY_BRANCH}"
git checkout "${_DEPLOY_BRANCH}"
git merge --ff-only "origin/${_DEPLOY_BRANCH}"
echo "webhook-deploy: npm ci + build (ingest-api, admin-ui, collector-worker, api)"
(cd "${_ROOT}/ingest-api" && npm ci && npm run build)
(cd "${_ROOT}/admin-ui" && npm ci && npm run build)
(cd "${_ROOT}/collector-worker" && npm ci && npm run build)
(cd "${_ROOT}/api" && npm ci && npm run build)
if getent passwd error-reporting >/dev/null 2>&1; then
chown -R error-reporting:error-reporting "${_ROOT}"
fi
"${_ROOT}/deploy/lxc/write-version-json.sh"
"${_ROOT}/deploy/lxc/verify.sh"
if [[ "${ER_WEBHOOK_RESTART_SERVICES:-1}" == "1" ]]; then
systemctl restart bitreport-error-reporting-ingest-api.service
systemctl restart bitreport-error-reporting-admin-ui.service
systemctl restart bitreport-error-reporting-collector-worker.service
fi
echo "webhook-deploy: done"