From e8ab59e070a08ea3555a9e576bea4e218a68d423 Mon Sep 17 00:00:00 2001 From: copilotcoder Date: Wed, 15 Jul 2026 11:47:08 -0400 Subject: [PATCH] Pin registry auth realm host for shared CI image jobs --- .gitea/workflows/cicd.yaml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/.gitea/workflows/cicd.yaml b/.gitea/workflows/cicd.yaml index 8dfdd36..410532c 100644 --- a/.gitea/workflows/cicd.yaml +++ b/.gitea/workflows/cicd.yaml @@ -563,6 +563,27 @@ jobs: - &configure_registry_host_step name: Configure registry host resolution run: | + ensure_registry_auth_realm_host() { + if ! grep -q "${GITEA_REGISTRY_HOST}" /etc/hosts; then + echo "${GITEA_REGISTRY_IP} ${GITEA_REGISTRY_HOST}" >> /etc/hosts + fi + + headers_file="$(mktemp)" + if curl -sSI "http://${GITEA_REGISTRY}/v2/" >"${headers_file}"; then + realm_url="$(sed -n 's/.*realm="\([^"]*\)".*/\1/p' "${headers_file}" | head -n 1)" + if [ -n "${realm_url}" ]; then + realm_host="$(printf '%s' "${realm_url}" | sed -E 's#^https?://([^/:]+).*$#\1#')" + if [ -n "${realm_host}" ] && [ "${realm_host}" != "${GITEA_REGISTRY_HOST}" ]; then + if ! grep -q "${realm_host}" /etc/hosts; then + echo "${GITEA_REGISTRY_IP} ${realm_host}" >> /etc/hosts + echo "Pinned registry auth realm host: ${realm_host} -> ${GITEA_REGISTRY_IP}" + fi + fi + fi + fi + rm -f "${headers_file}" + } + if [ "${CI_PRUNE_AT_JOB_START:-false}" = "true" ] && command -v docker >/dev/null 2>&1; then used_before="$(df -P / | awk 'NR==2 {gsub(/%/, "", $5); print $5}')" threshold="${CI_PRUNE_THRESHOLD_PERCENT:-90}" @@ -582,6 +603,8 @@ jobs: echo "${GITEA_REGISTRY_IP} ${GITEA_REGISTRY_HOST}" >> /etc/hosts fi + ensure_registry_auth_realm_host + - &ensure_cicd_image_step name: Ensure CICD image is available env: