Compare commits

2 Commits

Author SHA1 Message Date
d7e3545a84 Merge pull request 'Enhance Docker build workflow with additional API tests for registry authentication' (#3) from dev into main
Reviewed-on: #3
2026-07-07 12:40:41 +00:00
smueller
e4150d0bc3 Enhance Docker build workflow with additional API tests for registry authentication
- Introduce new diagnostic steps to validate registry login credentials, including checks for Basic-Auth and token requests.
- Implement curl commands to retrieve and display authentication details, improving debugging capabilities during the Docker build process.
2026-07-07 14:40:20 +02:00

View File

@@ -33,14 +33,30 @@ jobs:
REG_USER: ${{ secrets.REGISTRY_USER || github.repository_owner }} REG_USER: ${{ secrets.REGISTRY_USER || github.repository_owner }}
REG_TOKEN: ${{ secrets.REGISTRY_TOKEN }} REG_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
run: | run: |
IMAGE_LOWER=$(echo "${IMAGE_NAME}" | tr '[:upper:]' '[:lower:]')
echo "Registry: ${REGISTRY}" echo "Registry: ${REGISTRY}"
echo "Username: '${REG_USER}' (Laenge: ${#REG_USER})" echo "Username: '${REG_USER}' (Laenge: ${#REG_USER})"
echo "Token gesetzt: $([ -n "${REG_TOKEN}" ] && echo ja || echo NEIN) (Laenge: ${#REG_TOKEN})" echo "Token gesetzt: $([ -n "${REG_TOKEN}" ] && echo ja || echo NEIN) (Laenge: ${#REG_TOKEN})"
echo "--- Test 1: /v2/ mit Basic-Auth ---" echo "Image (lower): ${IMAGE_LOWER}"
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) ---" echo "--- API-Test: /api/v1/user (Basic-Auth gueltig?) ---"
curl -s -o /dev/null -w "HTTP %{http_code}\n" -u "${REG_USER}:${REG_TOKEN}" \ curl -s -o /dev/null -w "HTTP %{http_code}\n" -u "${REG_USER}:${REG_TOKEN}" "https://${REGISTRY}/api/v1/user"
"https://${REGISTRY}/v2/token?scope=repository:${IMAGE_NAME}:pull,push&service=container_registry" || true
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 - name: An Gitea Container Registry anmelden
uses: docker/login-action@v3 uses: docker/login-action@v3