Template
CI reads Infisical staging as the read-only convexmonorepo-base-ci machine identity, runs the quality gate, and builds and pushes the image. The template is not deployed, so there is no Convex or VPS deploy step. The local stack moves to its own Compose name and ports so it runs beside the Payload template's, and it syncs the Convex runtime env. The scripts pick up Infisical account switching, dev-kill and a cache-safe CI install.
48 lines
1.3 KiB
Bash
Executable File
48 lines
1.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
|
|
ROOT_DIR="$(cd -- "$SCRIPT_DIR/.." && pwd)"
|
|
VALUE_FILE=""
|
|
|
|
readonly RUNTIME_ENV_NAMES=(
|
|
AUTH_AUTHENTIK_ID
|
|
AUTH_AUTHENTIK_SECRET
|
|
AUTH_AUTHENTIK_ISSUER
|
|
USESEND_API_KEY
|
|
USESEND_URL
|
|
USESEND_FROM_EMAIL
|
|
)
|
|
readonly DEPLOYMENT_ENV_NAMES=(
|
|
CONVEX_SELF_HOSTED_URL
|
|
CONVEX_SELF_HOSTED_ADMIN_KEY
|
|
)
|
|
|
|
die() { printf 'sync-local-convex-env: %s\n' "$*" >&2; exit 1; }
|
|
cleanup() {
|
|
if [ -n "$VALUE_FILE" ] && [ -f "$VALUE_FILE" ]; then
|
|
rm -f "$VALUE_FILE"
|
|
fi
|
|
}
|
|
trap cleanup EXIT INT TERM HUP
|
|
|
|
for name in "${DEPLOYMENT_ENV_NAMES[@]}" "${RUNTIME_ENV_NAMES[@]}"; do
|
|
[ -n "${!name:-}" ] || die "Missing required environment variable: $name"
|
|
done
|
|
|
|
VALUE_FILE="$(mktemp "${TMPDIR:-/tmp}/convex-monorepo-convex-env.value.XXXXXX")"
|
|
chmod 600 "$VALUE_FILE"
|
|
|
|
for name in "${RUNTIME_ENV_NAMES[@]}"; do
|
|
printf '%s' "${!name}" > "$VALUE_FILE"
|
|
(
|
|
cd "$ROOT_DIR/packages/backend"
|
|
env -u CONVEX_DEPLOY_KEY -u CONVEX_DEPLOYMENT \
|
|
CONVEX_SELF_HOSTED_URL="$CONVEX_SELF_HOSTED_URL" \
|
|
CONVEX_SELF_HOSTED_ADMIN_KEY="$CONVEX_SELF_HOSTED_ADMIN_KEY" \
|
|
bunx convex env set "$name" --from-file "$VALUE_FILE" >/dev/null
|
|
)
|
|
done
|
|
|
|
printf 'Local Convex runtime environment synchronized.\n'
|