ci(oidc): build isolated imported Login image and reuse real browser acceptance

This commit is contained in:
victorsteele428 committed 2026-11-23 10:16:45 +00:00
1 parent c93468fb60
commit fcfa59e826
7 files changed
+214 -4

No files matched your search

+49
View File
@@ -0,0 +1,49 @@
#!/bin/sh
# Idempotent always() teardown for ONLY this workflow's builder/image/context.
# The previous OIDC owned cleanup MUST run before removing the image.
set -eu
: "${GITHUB_RUN_ID:?Missing run ID}"
case "$GITHUB_RUN_ID" in *[!0-9]*|'') echo LOGIN_CI_CLEANUP_INVALID_RUN_ID >&2; exit 1;; esac
builder="zitplane-login-$GITHUB_RUN_ID-builder"
image="zitplane-login-ci:$GITHUB_RUN_ID"
context="/tmp/zitplane-login-build-$GITHUB_RUN_ID"
rc=0
if docker container inspect "$builder" >/dev/null 2>&1; then
label="$(docker inspect -f '{{ index .Config.Labels "zitplane.login.run" }}' "$builder" 2>/dev/null || true)"
if [ "$label" != "$GITHUB_RUN_ID" ]; then
echo ZITPLANE_CUSTOM_LOGIN_UNOWNED_BUILDER_REFUSED >&2
rc=1
elif ! docker rm -f "$builder" >/dev/null; then
echo ZITPLANE_CUSTOM_LOGIN_BUILDER_CLEANUP_FAILED >&2
rc=1
fi
fi
if docker image inspect "$image" >/dev/null 2>&1; then
label="$(docker image inspect --format '{{ index .Config.Labels "zitplane.login.run" }}' "$image" 2>/dev/null || true)"
if [ "$label" != "$GITHUB_RUN_ID" ]; then
echo ZITPLANE_CUSTOM_LOGIN_UNOWNED_IMAGE_REFUSED >&2
rc=1
elif ! docker image rm "$image" >/dev/null; then
echo ZITPLANE_CUSTOM_LOGIN_LOCAL_IMAGE_CLEANUP_FAILED >&2
rc=1
fi
fi
if [ -e "$context" ]; then
if [ -f "$context/.zitplane-owned-$GITHUB_RUN_ID" ]; then
rm -rf "$context"
else
echo ZITPLANE_CUSTOM_LOGIN_UNOWNED_CONTEXT_REFUSED >&2
rc=1
fi
fi
if docker container inspect "$builder" >/dev/null 2>&1 ||
docker image inspect "$image" >/dev/null 2>&1 ||
[ -e "$context" ]; then
echo ZITPLANE_CUSTOM_LOGIN_RESOURCES_LEFTOVER >&2
rc=1
fi
if [ "$rc" -ne 0 ]; then
echo ZITPLANE_CUSTOM_LOGIN_CLEANUP_FAILED >&2
exit 1
fi
echo ZITPLANE_CUSTOM_LOGIN_ALL_BUILD_RESOURCES_CLEANED_PASS