Stabilize self-hosted CI workflows and resolve issue #62 #73
@@ -194,6 +194,27 @@ jobs:
|
||||
return 1
|
||||
}
|
||||
|
||||
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 ! grep -q "${GITEA_REGISTRY_HOST}" /etc/hosts; then
|
||||
echo "${GITEA_REGISTRY_IP} ${GITEA_REGISTRY_HOST}" >> /etc/hosts
|
||||
fi
|
||||
@@ -373,6 +394,8 @@ jobs:
|
||||
docker system df || true
|
||||
fi
|
||||
|
||||
ensure_registry_auth_realm_host
|
||||
|
||||
echo "${PACKAGE_ACCESS_TOKEN}" | docker login "http://${GITEA_REGISTRY}" -u "${REGISTRY_USER}" --password-stdin
|
||||
|
||||
RESOLVED_HEAD_SHA="$(trim_spaces "${HEAD_SHA:-}")"
|
||||
|
||||
Reference in New Issue
Block a user