- qa/site-qa.sh: repo structure/link checks + full live crawl (routes, links, assets, canonical-https) - .gitea/workflows/qa.yml: repo QA on push, nightly live QA - app/: config-as-code for the deployed sync job, scheduler entry, and Grav system.yaml (reverse-proxy HTTPS detection) - local pre-push hook runs repo QA https://projects.knownelement.com/issues/928
45 lines
1.7 KiB
Bash
45 lines
1.7 KiB
Bash
#!/bin/bash
|
|
# git-sync-job.sh v2 - deploy upstream, verify, roll back on failure.
|
|
# Pull: if upstream moved -> deploy + clearcache + verify key routes; rollback on failure.
|
|
# Push: if local pages edits exist -> commit + push (VpEngOps identity).
|
|
cd /app/data/user || exit 1
|
|
GIT=/usr/bin/git
|
|
BASE="https://${CLOUDRON_APP_DOMAIN}"
|
|
PORT="${CLOUDRON_APP_PORT:-80}"
|
|
verify() { # returns 0 if key routes answer 200
|
|
sleep 2
|
|
for r in / /shop; do
|
|
code=$(curl -s -o /dev/null -w '%{http_code}' -m 10 "http://127.0.0.1:${PORT}${r}" 2>/dev/null)
|
|
[ "$code" != "200" ] && { echo "$(date -u +%FT%TZ) ALARM: route $r -> $code after deploy"; return 1; }
|
|
done
|
|
return 0
|
|
}
|
|
$GIT fetch origin main 2>/dev/null || exit 0
|
|
LOCAL=$($GIT rev-parse HEAD 2>/dev/null || echo none)
|
|
REMOTE=$($GIT rev-parse origin/main 2>/dev/null || echo none)
|
|
if [ "$LOCAL" != "$REMOTE" ]; then
|
|
if [ "$LOCAL" = "none" ]; then
|
|
$GIT checkout -f -B main origin/main || exit 0
|
|
else
|
|
PREV=$LOCAL
|
|
$GIT reset --hard origin/main || exit 0
|
|
fi
|
|
$GIT clean -fdq pages/ 2>/dev/null
|
|
cd /app/code && php bin/grav clearcache >/dev/null 2>&1; cd /app/data/user
|
|
if ! verify; then
|
|
if [ -n "${PREV:-}" ]; then
|
|
$GIT reset --hard "$PREV" && $GIT clean -fdq pages/ 2>/dev/null
|
|
cd /app/code && php bin/grav clearcache >/dev/null 2>&1
|
|
echo "$(date -u +%FT%TZ) rolled back to $PREV"
|
|
fi
|
|
exit 1
|
|
fi
|
|
echo "$(date -u +%FT%TZ) deployed $REMOTE"
|
|
exit 0
|
|
fi
|
|
if ! $GIT diff --quiet || ! $GIT diff --cached --quiet; then
|
|
$GIT add pages/
|
|
$GIT -c user.name=VpEngOps -c user.email=tsgstaff-coo-vpengops@turnsys.com commit -qm '(Grav site) content changes' || exit 0
|
|
fi
|
|
$GIT push origin main 2>/dev/null && echo "$(date -u +%FT%TZ) pushed" || true
|