Fix deployment verification and clean submission
هذا الالتزام موجود في:
@@ -1,66 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Deployment adapter for the GitHub Actions workflow.
|
||||
#
|
||||
# Ghaymah publicly documents `gy resource app launch` for deploying a
|
||||
# local Dockerfile/.ghaymah.json project. It does not currently document a
|
||||
# non-interactive API-token login command. The current binary exposes
|
||||
# email/password login flags and a generic `app update` command, but its public
|
||||
# help does not identify an external-image field. This adapter therefore
|
||||
# validates and prints the exact deployment handoff, then fails deliberately
|
||||
# instead of reporting a deployment that did not happen.
|
||||
|
||||
app=""
|
||||
image=""
|
||||
|
||||
usage() {
|
||||
echo "Usage: $0 --app <application-name> --image <registry/image:tag>" >&2
|
||||
}
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--app)
|
||||
[[ $# -ge 2 ]] || { usage; exit 64; }
|
||||
app="$2"
|
||||
shift 2
|
||||
;;
|
||||
--image)
|
||||
[[ $# -ge 2 ]] || { usage; exit 64; }
|
||||
image="$2"
|
||||
shift 2
|
||||
;;
|
||||
*)
|
||||
echo "Unknown argument: $1" >&2
|
||||
usage
|
||||
exit 64
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
[[ -n "$app" && -n "$image" ]] || { usage; exit 64; }
|
||||
|
||||
echo "Ghaymah deployment handoff"
|
||||
echo " Application: $app"
|
||||
echo " Image URL: $image"
|
||||
echo
|
||||
echo "Update the target application's container image URL to the immutable tag"
|
||||
echo "shown above in the Ghaymah dashboard, then validate its health endpoint."
|
||||
echo
|
||||
echo "Automated deployment is intentionally blocked because the public CLI docs"
|
||||
echo "do not specify API-token authentication or the external-image field for"
|
||||
echo "'gy resource app update'. Replace this adapter only with confirmed syntax."
|
||||
|
||||
if [[ -n "${GITHUB_STEP_SUMMARY:-}" ]]; then
|
||||
{
|
||||
echo "### Ghaymah deployment requires confirmed integration"
|
||||
echo
|
||||
echo "- Application: \`$app\`"
|
||||
echo "- Image: \`$image\`"
|
||||
echo
|
||||
echo "The image was built and pushed, but no deployment was claimed. Confirm"
|
||||
echo "the supported API/CLI command or update this image URL in the dashboard."
|
||||
} >> "$GITHUB_STEP_SUMMARY"
|
||||
fi
|
||||
|
||||
exit 78
|
||||
80
scripts/verify_deployment.sh
Normal file
80
scripts/verify_deployment.sh
Normal file
@@ -0,0 +1,80 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Verify that a deployed service is healthy and exposes the expected immutable
|
||||
# release identifier. This prevents a manually promoted Ghaymah deployment from
|
||||
# being reported as successful when it is still serving an older image.
|
||||
|
||||
app=""
|
||||
url=""
|
||||
expected_release=""
|
||||
attempts="${DEPLOY_CHECK_ATTEMPTS:-30}"
|
||||
interval_s="${DEPLOY_CHECK_INTERVAL_S:-2}"
|
||||
|
||||
usage() {
|
||||
echo "Usage: $0 --app <name> --url <base-url> --expected-release <git-sha>" >&2
|
||||
}
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--app)
|
||||
[[ $# -ge 2 ]] || { usage; exit 64; }
|
||||
app="$2"
|
||||
shift 2
|
||||
;;
|
||||
--url)
|
||||
[[ $# -ge 2 ]] || { usage; exit 64; }
|
||||
url="${2%/}"
|
||||
shift 2
|
||||
;;
|
||||
--expected-release)
|
||||
[[ $# -ge 2 ]] || { usage; exit 64; }
|
||||
expected_release="$2"
|
||||
shift 2
|
||||
;;
|
||||
*)
|
||||
echo "Unknown argument: $1" >&2
|
||||
usage
|
||||
exit 64
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
[[ -n "$app" && -n "$url" && -n "$expected_release" ]] || { usage; exit 64; }
|
||||
[[ "$attempts" =~ ^[1-9][0-9]*$ ]] || { echo "DEPLOY_CHECK_ATTEMPTS must be a positive integer" >&2; exit 64; }
|
||||
[[ "$interval_s" =~ ^[0-9]+$ ]] || { echo "DEPLOY_CHECK_INTERVAL_S must be a non-negative integer" >&2; exit 64; }
|
||||
|
||||
health_url="${url}/health"
|
||||
echo "Verifying ${app} at ${health_url}"
|
||||
|
||||
for ((attempt = 1; attempt <= attempts; attempt++)); do
|
||||
body="$(curl --fail --silent --show-error --max-time 5 "$health_url" 2>/dev/null || true)"
|
||||
|
||||
if [[ -n "$body" ]]; then
|
||||
status="$(sed -n 's/.*"status"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' <<<"$body")"
|
||||
release="$(sed -n 's/.*"release"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' <<<"$body")"
|
||||
|
||||
if [[ "$status" == "ok" && "$release" == "$expected_release" ]]; then
|
||||
echo "Deployment verified: status=ok release=${release}"
|
||||
if [[ -n "${GITHUB_STEP_SUMMARY:-}" ]]; then
|
||||
{
|
||||
echo "### Deployment verified"
|
||||
echo
|
||||
echo "- Application: \`${app}\`"
|
||||
echo "- URL: ${url}"
|
||||
echo "- Release: \`${release}\`"
|
||||
} >>"$GITHUB_STEP_SUMMARY"
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Attempt ${attempt}/${attempts}: status=${status:-missing}, release=${release:-missing}"
|
||||
else
|
||||
echo "Attempt ${attempt}/${attempts}: health endpoint unavailable"
|
||||
fi
|
||||
|
||||
((attempt == attempts)) || sleep "$interval_s"
|
||||
done
|
||||
|
||||
echo "Deployment verification failed for ${app}: expected release ${expected_release}" >&2
|
||||
exit 1
|
||||
المرجع في مشكلة جديدة
حظر مستخدم