mirror of
https://github.com/pezkuwichain/pezkuwi-telegram-miniapp.git
synced 2026-11-01 08:29:51 +00:00
The deploy reached VPS3 as root with one key, handed to appleboy actions referenced by tag, and on every run it reinstalled the edge-function ownership gate and its registry as root. That gate guards every project's functions in the shared volume, so any change merged here could rewrite the rule that protects pwap's functions. Now CI connects as miniapp-deploy with two keys, each pinned on the host (authorized_keys restrict,command=) to a script in ops/host: - MINIAPP_SITE_DEPLOY_KEY -> miniapp-site-receive: the site tar on stdin, into /var/www/telegram.pezkiwi.app, nothing else. - MINIAPP_FUNCTIONS_DEPLOY_KEY -> miniapp-functions-ssh: `gate-sha`, or `deploy` with functions.tgz on stdin, run through sudo for exactly those arguments. Root installs the gate and registry from ops/; the deploy checks the host's copies against them and refuses to deploy functions while they differ. The asset cleanup that ran after each deploy (/opt/cleanup-miniapp.sh, only on the host) protected lazy chunks by mtime and so removed live ones when a build was shipped more than two hours after it was made; it took seven pages down for about two minutes on 2026-10-09 while this was being tested, and they were restored from the same tar. The receive script now keeps every file of the new build and removes other assets only after four hours. Its tests cover that (red with the keep rule removed) and the refusals; CI runs them with shellcheck, and apply-repo-settings.sh requires the job. VPS3's host key is pinned. The commented-out VPS1 deploy is gone; that host no longer exists. Every action is pinned to a commit SHA.
31 lines
1.1 KiB
Bash
Executable File
31 lines
1.1 KiB
Bash
Executable File
#!/bin/bash
|
|
# Deploys this project's edge functions into the shared Supabase volume,
|
|
# through the ownership gate (supabase-deploy-functions), from a functions.tgz
|
|
# on stdin. Installed root-owned at /usr/local/sbin/miniapp-functions-deploy;
|
|
# reached only through miniapp-functions-ssh.
|
|
#
|
|
# The gate and its registry guard every project's functions in that volume,
|
|
# so CI does not install them: root does, from ops/ in this repository, and
|
|
# CI checks with `gate-sha` that the host runs what the repository says.
|
|
set -euo pipefail
|
|
|
|
GATE=/usr/local/bin/supabase-deploy-functions
|
|
REGISTRY=/opt/supabase-self-hosted/functions-registry.json
|
|
|
|
case "${1:-}" in
|
|
gate-sha)
|
|
sha256sum "$GATE" "$REGISTRY" | awk '{print $1}'
|
|
;;
|
|
deploy)
|
|
BASE=$(mktemp -d /opt/miniapp-deploy-staging.XXXXXX)
|
|
trap 'rm -rf "$BASE"' EXIT
|
|
tar -xzf - -C "$BASE" --no-same-owner
|
|
[ -d "$BASE/functions" ] || { echo "miniapp-functions-deploy: the bundle has no functions/" >&2; exit 1; }
|
|
"$GATE" --project pezkuwi-telegram-miniapp --src "$BASE/functions" --restart
|
|
;;
|
|
*)
|
|
echo "usage: miniapp-functions-deploy gate-sha|deploy" >&2
|
|
exit 2
|
|
;;
|
|
esac
|