Verify Secrets #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Verify Secrets | |
| on: workflow_dispatch | |
| jobs: | |
| verify: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Verify Secrets Presence | |
| run: | | |
| if [ -n "${{ secrets.OSSRH_TOKEN_USERNAME }}" ]; then echo "OSSRH_TOKEN_USERNAME is set"; else echo "OSSRH_TOKEN_USERNAME is MISSING"; fi | |
| if [ -n "${{ secrets.OSSRH_TOKEN_PASSWORD }}" ]; then echo "OSSRH_TOKEN_PASSWORD is set"; else echo "OSSRH_TOKEN_PASSWORD is MISSING"; fi | |
| - name: Test Connection to OSSRH | |
| run: | | |
| echo "Testing authentication with OSSRH..." | |
| # 尝试访问 OSSRH 状态接口,如果返回 200 则说明账号密码正确 | |
| HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" -u "${{ secrets.OSSRH_TOKEN_USERNAME }}:${{ secrets.OSSRH_TOKEN_PASSWORD }}" "https://ossrh-staging-api.central.sonatype.com/service/local/status") | |
| echo "HTTP Status Code: $HTTP_CODE" | |
| if [ "$HTTP_CODE" -eq 200 ]; then | |
| echo "Authentication SUCCESSFUL!" | |
| else | |
| echo "Authentication FAILED! Status code: $HTTP_CODE" | |
| echo "Please check your OSSRH_TOKEN_USERNAME and OSSRH_TOKEN_PASSWORD secrets." | |
| exit 1 | |
| fi |