Bounded Stage v4 credential acceptance window / acceptance-window (push) Failing after 3m22s
36 lines
3.1 KiB
Bash
36 lines
3.1 KiB
Bash
#!/usr/bin/env bash
|
|
# CI job side only. Never execute host deploy logic in the runner filesystem.
|
|
set -euo pipefail
|
|
set +x
|
|
fail() { printf 'ERROR: %s\n' "$1" >&2; exit 2; }
|
|
[[ ${GITHUB_ACTIONS:-${GITEA_ACTIONS:-}} == true && $# == 0 ]] || fail 'CI-only Stage operation'
|
|
case ${BRANCH:-} in
|
|
develop) ;;
|
|
ci/v4-stage-resume-1a00-860324e)
|
|
[[ ${DEPLOY_SHA:-} == 860324e3a91b31c2b6d4e784e458f6d120582cb8 && ${STAGE_TEST_SESSION:-} == v4-ci-resume-1a00-20261024 && ${STAGE_TEST_TTL_SECONDS:-} == 600 ]] || fail 'fixed acceptance scope required'
|
|
;;
|
|
*) fail 'Stage branch required; Production is blocked' ;;
|
|
esac
|
|
[[ ${STAGE_TEST_ACTION:-} != open || ${BRANCH:-} != ci/v4-stage-resume-1a00-860324e || ${GITHUB_RUN_ATTEMPT:-} == 1 ]] || fail 'acceptance reruns blocked'
|
|
[[ ${DEPLOY_SHA:-} =~ ^[0-9a-f]{40}$ ]] || fail 'immutable DEPLOY_SHA required'
|
|
# Repository secret DEPLOY_KEY is the historical approved devops SSH credential.
|
|
# Never fall back to baked-in runner keys, agent forwarding or docker.sock.
|
|
[[ -n ${DEPLOY_KNOWN_HOSTS:-} ]] || fail 'provision DEPLOY_KNOWN_HOSTS: independently verified [87.248.133.138]:2234 host key; never use ssh-keyscan trust-on-first-use'
|
|
[[ -n ${DEPLOY_KEY:-} ]] || fail 'provision existing approved DEPLOY_KEY for devops@87.248.133.138:2234'
|
|
for tool in ssh ssh-keygen mktemp; do command -v "$tool" >/dev/null || fail "job context missing $tool"; done
|
|
umask 077
|
|
scratch=$(mktemp -d)
|
|
trap 'rm -rf "$scratch"' EXIT
|
|
printf '%s\n' "$DEPLOY_KNOWN_HOSTS" > "$scratch/known_hosts"
|
|
printf '%s\n' "$DEPLOY_KEY" > "$scratch/key"
|
|
unset DEPLOY_KEY DEPLOY_KNOWN_HOSTS
|
|
ssh-keygen -F '[87.248.133.138]:2234' -f "$scratch/known_hosts" >/dev/null || fail 'DEPLOY_KNOWN_HOSTS has no pinned deployment endpoint'
|
|
[[ ${STAGE_TEST_SESSION:-} =~ ^[a-z0-9-]{8,64}$ && ${STAGE_TEST_TTL_SECONDS:-} =~ ^[0-9]+$ && ${STAGE_TEST_ACTION:-} =~ ^(open|close|accept)$ && ${STAGE_TEST_APPROVAL:-} == owner-authorized-stage-editorial ]] || fail 'explicit owner Stage test grant required'
|
|
[[ $STAGE_TEST_TTL_SECONDS -ge 60 && $STAGE_TEST_TTL_SECONDS -le 3600 ]] || exit 2
|
|
if [[ $STAGE_TEST_ACTION == accept ]]; then
|
|
[[ $BRANCH == ci/v4-stage-resume-1a00-860324e && $GITHUB_RUN_ATTEMPT == 1 ]] || fail 'acceptance scope required'
|
|
ssh -F /dev/null -T -p 2234 -i "$scratch/key" -o BatchMode=yes -o IdentitiesOnly=yes -o IdentityAgent=none -o StrictHostKeyChecking=yes -o UserKnownHostsFile="$scratch/known_hosts" -o GlobalKnownHostsFile=/dev/null -o ConnectTimeout=15 devops@87.248.133.138 "sudo -n timeout --signal=TERM --kill-after=10 480 python3 -" < "$(dirname "${BASH_SOURCE[0]}")/stage-editorial-acceptance.py"
|
|
exit $?
|
|
fi
|
|
ssh -F /dev/null -T -p 2234 -i "$scratch/key" -o BatchMode=yes -o IdentitiesOnly=yes -o IdentityAgent=none -o StrictHostKeyChecking=yes -o UserKnownHostsFile="$scratch/known_hosts" -o GlobalKnownHostsFile=/dev/null -o ConnectTimeout=15 devops@87.248.133.138 "sudo -n env CI=true STAGE_TEST_APPROVAL=owner-authorized-stage-editorial bash /opt/services/canina/releases/$DEPLOY_SHA/scripts/stage-test-principal-host.sh $DEPLOY_SHA $STAGE_TEST_SESSION $STAGE_TEST_TTL_SECONDS $STAGE_TEST_ACTION"
|