Skip to content

Commit af7a67b

Browse files
ankitdas13claude
andcommitted
fix(ci): harden Central Portal credential validation
Switch probe to /publisher/status (auth-only) and treat non-2xx as failure with retries on 5xx, so bad credentials or Portal outages can no longer sail through the dry-run step as a warning. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent b2ace4a commit af7a67b

1 file changed

Lines changed: 25 additions & 13 deletions

File tree

.github/workflows/ci.yml

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -87,19 +87,31 @@ jobs:
8787
echo "✗ CENTRAL_USERNAME or CENTRAL_TOKEN secrets are not set"
8888
exit 1
8989
fi
90-
HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" -u "${CENTRAL_USERNAME}:${CENTRAL_TOKEN}" \
91-
"https://central.sonatype.com/api/v1/publisher/published?namespace=com.razorpay&name=razorpay-java")
92-
if [ "$HTTP_STATUS" -eq 200 ]; then
93-
echo "✓ Central Portal credentials are valid (HTTP $HTTP_STATUS)"
94-
elif [ "$HTTP_STATUS" -eq 401 ]; then
95-
echo "✗ Central Portal credentials are invalid (HTTP 401 Unauthorized)"
96-
exit 1
97-
elif [ "$HTTP_STATUS" -eq 403 ]; then
98-
echo "✗ Central Portal credentials lack permission (HTTP 403 Forbidden)"
99-
exit 1
100-
else
101-
echo "⚠ Unexpected response from Central Portal (HTTP $HTTP_STATUS) — credentials may still be valid"
102-
fi
90+
for attempt in 1 2 3; do
91+
HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" \
92+
-u "${CENTRAL_USERNAME}:${CENTRAL_TOKEN}" \
93+
"https://central.sonatype.com/api/v1/publisher/status")
94+
case "$HTTP_STATUS" in
95+
200)
96+
echo "✓ Central Portal credentials are valid (HTTP 200)"
97+
exit 0
98+
;;
99+
401|403)
100+
echo "✗ Central Portal rejected credentials (HTTP $HTTP_STATUS)"
101+
exit 1
102+
;;
103+
5*)
104+
echo "⚠ Attempt $attempt: transient error (HTTP $HTTP_STATUS), retrying in 5s…"
105+
sleep 5
106+
;;
107+
*)
108+
echo "✗ Unexpected response from Central Portal (HTTP $HTTP_STATUS)"
109+
exit 1
110+
;;
111+
esac
112+
done
113+
echo "✗ Central Portal unreachable after 3 attempts"
114+
exit 1
103115
104116
publish:
105117
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch'

0 commit comments

Comments
 (0)