Enhance Docker build workflow with additional API tests for registry authentication #3

Merged
smueller merged 1 commits from dev into main 2026-07-07 12:40:41 +00:00
Showing only changes of commit e4150d0bc3 - Show all commits

View File

@@ -33,14 +33,30 @@ jobs:
REG_USER: ${{ secrets.REGISTRY_USER || github.repository_owner }}
REG_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
run: |
IMAGE_LOWER=$(echo "${IMAGE_NAME}" | tr '[:upper:]' '[:lower:]')
echo "Registry: ${REGISTRY}"
echo "Username: '${REG_USER}' (Laenge: ${#REG_USER})"
echo "Token gesetzt: $([ -n "${REG_TOKEN}" ] && echo ja || echo NEIN) (Laenge: ${#REG_TOKEN})"
echo "--- Test 1: /v2/ mit Basic-Auth ---"
curl -s -o /dev/null -w "HTTP %{http_code}\n" -u "${REG_USER}:${REG_TOKEN}" "https://${REGISTRY}/v2/"
echo "--- Test 2: Token-Endpoint (Bearer-Flow) ---"
curl -s -o /dev/null -w "HTTP %{http_code}\n" -u "${REG_USER}:${REG_TOKEN}" \
"https://${REGISTRY}/v2/token?scope=repository:${IMAGE_NAME}:pull,push&service=container_registry" || true
echo "Image (lower): ${IMAGE_LOWER}"
echo "--- API-Test: /api/v1/user (Basic-Auth gueltig?) ---"
curl -s -o /dev/null -w "HTTP %{http_code}\n" -u "${REG_USER}:${REG_TOKEN}" "https://${REGISTRY}/api/v1/user"
echo "--- /v2/ Challenge (WWW-Authenticate) ---"
HDR=$(curl -s -D - -o /dev/null "https://${REGISTRY}/v2/")
AUTH=$(printf '%s' "$HDR" | tr -d '\r' | grep -i '^www-authenticate:' || true)
echo "${AUTH:-(keine WWW-Authenticate Zeile)}"
REALM=$(printf '%s' "$AUTH" | sed -n 's/.*realm="\([^"]*\)".*/\1/p')
SERVICE=$(printf '%s' "$AUTH" | sed -n 's/.*service="\([^"]*\)".*/\1/p')
echo "realm='${REALM}' service='${SERVICE}'"
if [ -n "${REALM}" ]; then
echo "--- Token-Request am echten realm ---"
CODE=$(curl -s -o /tmp/tok.json -w "%{http_code}" -u "${REG_USER}:${REG_TOKEN}" \
"${REALM}?service=${SERVICE}&scope=repository:${IMAGE_LOWER}:pull,push")
echo "HTTP ${CODE}"
echo "Antwort (gekuerzt): $(head -c 300 /tmp/tok.json)"
fi
- name: An Gitea Container Registry anmelden
uses: docker/login-action@v3