From e9d8ddc418880c51651fc26204095c11108b18f0 Mon Sep 17 00:00:00 2001 From: Jean-Luc Makiola Date: Sat, 11 Apr 2026 00:31:57 +0200 Subject: [PATCH] fix: strip whitespace from Coolify token in deploy step Root cause: COOLIFY_TOKEN secret had a leading space (0x20) causing 401 Unauthenticated. Strip whitespace with tr before passing to curl. Also removes debug diagnostics. Co-Authored-By: Claude Opus 4.6 (1M context) --- .gitea/workflows/ci.yml | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 8647aa6..4be6605 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -58,24 +58,14 @@ jobs: COOLIFY_TOKEN: ${{ secrets.COOLIFY_TOKEN }} COOLIFY_WEBHOOK: ${{ vars.COOLIFY_WEBHOOK }} run: | - echo "Token length: ${#COOLIFY_TOKEN}" - echo "Token first 3 chars: $(printf '%.3s' "${COOLIFY_TOKEN}")" - printf '%s' "${COOLIFY_TOKEN}" | hexdump -C | head -4 - echo "Webhook URL: ${COOLIFY_WEBHOOK}" - echo "--- Attempt 1: manual Bearer header ---" + TOKEN=$(printf '%s' "${COOLIFY_TOKEN}" | tr -d '[:space:]') RESPONSE=$(curl -s -w '\n%{http_code}' -X GET "${COOLIFY_WEBHOOK}" \ - -H "Authorization: Bearer ${COOLIFY_TOKEN}") + -H "Authorization: Bearer ${TOKEN}") STATUS=$(echo "$RESPONSE" | tail -1) BODY=$(echo "$RESPONSE" | sed '$d') - echo "HTTP ${STATUS} - ${BODY}" - echo "--- Attempt 2: curl --oauth2-bearer ---" - RESPONSE2=$(curl -s -w '\n%{http_code}' -X GET "${COOLIFY_WEBHOOK}" \ - --oauth2-bearer "${COOLIFY_TOKEN}") - STATUS2=$(echo "$RESPONSE2" | tail -1) - BODY2=$(echo "$RESPONSE2" | sed '$d') - echo "HTTP ${STATUS2} - ${BODY2}" - if [ "$STATUS" -ge 400 ] && [ "$STATUS2" -ge 400 ]; then - echo "::error::Coolify deploy failed - both attempts returned errors" + echo "Coolify deploy: HTTP ${STATUS}" + if [ "$STATUS" -ge 400 ]; then + echo "::error::Coolify deploy failed with HTTP ${STATUS} - ${BODY}" exit 1 fi