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) <noreply@anthropic.com>
This commit is contained in:
@@ -58,24 +58,14 @@ jobs:
|
|||||||
COOLIFY_TOKEN: ${{ secrets.COOLIFY_TOKEN }}
|
COOLIFY_TOKEN: ${{ secrets.COOLIFY_TOKEN }}
|
||||||
COOLIFY_WEBHOOK: ${{ vars.COOLIFY_WEBHOOK }}
|
COOLIFY_WEBHOOK: ${{ vars.COOLIFY_WEBHOOK }}
|
||||||
run: |
|
run: |
|
||||||
echo "Token length: ${#COOLIFY_TOKEN}"
|
TOKEN=$(printf '%s' "${COOLIFY_TOKEN}" | tr -d '[:space:]')
|
||||||
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 ---"
|
|
||||||
RESPONSE=$(curl -s -w '\n%{http_code}' -X GET "${COOLIFY_WEBHOOK}" \
|
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)
|
STATUS=$(echo "$RESPONSE" | tail -1)
|
||||||
BODY=$(echo "$RESPONSE" | sed '$d')
|
BODY=$(echo "$RESPONSE" | sed '$d')
|
||||||
echo "HTTP ${STATUS} - ${BODY}"
|
echo "Coolify deploy: HTTP ${STATUS}"
|
||||||
echo "--- Attempt 2: curl --oauth2-bearer ---"
|
if [ "$STATUS" -ge 400 ]; then
|
||||||
RESPONSE2=$(curl -s -w '\n%{http_code}' -X GET "${COOLIFY_WEBHOOK}" \
|
echo "::error::Coolify deploy failed with HTTP ${STATUS} - ${BODY}"
|
||||||
--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"
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user