From c8df20bbeede9fd74a091baf9b5d0d3940ada4c4 Mon Sep 17 00:00:00 2001 From: Marc Mintel Date: Wed, 4 Mar 2026 11:37:20 +0100 Subject: [PATCH] ci: add whitespace trimming and api diagnostic to registry auth token loop --- .gitea/workflows/deploy.yml | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index f77408f..10f8f72 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -182,8 +182,14 @@ jobs: VALID_TOKEN="" VALID_USER="" - for T in $TOKENS; do - if [ -n "$T" ]; then + for T_RAW in $TOKENS; do + if [ -n "$T_RAW" ]; then + T=$(echo "$T_RAW" | tr -d ' ' | tr -d '\n' | tr -d '\r') + + echo "Testing API with token..." + HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" -H "Authorization: token $T" https://git.infra.mintel.me/api/v1/user || echo "failed") + echo "API returned: $HTTP_CODE" + for U in $USERS; do if [ -n "$U" ]; then echo "Attempting docker login for a token with user $U..." @@ -314,8 +320,9 @@ jobs: TOKENS="${{ secrets.GITHUB_TOKEN }} ${{ secrets.GITEA_PAT }} ${{ secrets.MINTEL_PRIVATE_TOKEN }} ${{ secrets.NPM_TOKEN }}" USERS="${{ github.repository_owner }} ${{ github.actor }} marcmintel mintel mmintel" - for TOKEN in $TOKENS; do - if [ -n "$TOKEN" ]; then + for TOKEN_RAW in $TOKENS; do + if [ -n "$TOKEN_RAW" ]; then + TOKEN=$(echo "$TOKEN_RAW" | tr -d ' ' | tr -d '\n' | tr -d '\r') for U in $USERS; do if [ -n "$U" ]; then echo "Attempting docker login for a token with user $U..." @@ -534,8 +541,9 @@ jobs: VALID_TOKEN="" VALID_USER="" - for T in $TOKENS; do - if [ -n "$T" ]; then + for T_RAW in $TOKENS; do + if [ -n "$T_RAW" ]; then + T=$(echo "$T_RAW" | tr -d ' ' | tr -d '\n' | tr -d '\r') for U in $USERS; do if [ -n "$U" ]; then echo "Attempting docker login for a token with user $U..." @@ -607,13 +615,14 @@ jobs: USERS="${{ github.repository_owner }} ${{ github.actor }} marcmintel mintel mmintel" VALID_TOKEN="" - for T in $TOKENS; do - if [ -n "$T" ]; then + for TOKEN_RAW in $TOKENS; do + if [ -n "$TOKEN_RAW" ]; then + TOKEN=$(echo "$TOKEN_RAW" | tr -d '[:space:]' | tr -d '\n' | tr -d '\r') for U in $USERS; do if [ -n "$U" ]; then - if echo "$T" | docker login git.infra.mintel.me -u "$U" --password-stdin > /dev/null 2>&1; then + if echo "$TOKEN" | docker login git.infra.mintel.me -u "$U" --password-stdin > /dev/null 2>&1; then echo "✅ Successfully authenticated with a token." - VALID_TOKEN="$T" + VALID_TOKEN="$TOKEN" break 2 fi fi