File tree Expand file tree Collapse file tree 1 file changed +16
-4
lines changed
Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -122,11 +122,23 @@ runs:
122122 env :
123123 GH_TOKEN : ${{ inputs.api-token }}
124124 run : |
125- if ! gh api repos/${{ github.repository }} --silent; then
125+ if [ -z "$GH_TOKEN" ]; then
126+ echo "::error::GitHub token is empty. Please verify the token is passed correctly."
127+ exit 1
128+ fi
129+
130+ if echo "$GH_TOKEN" | grep -q '[[:space:]]'; then
131+ echo "::error::GitHub token contains whitespace characters (newlines, spaces, etc). This suggests the token secret may be malformed."
132+ exit 1
133+ fi
134+
135+ if ! gh api repos/${{ github.repository }} --silent 2>&1; then
126136 echo "::error::GitHub token validation failed. Please verify:"
127- echo " 1. Token has not expired"
128- echo " 2. Token has an expiration date set"
129- echo " 3. Token has 'repo' and 'workflow' scopes"
137+ echo " 1. Token is not empty or malformed"
138+ echo " 2. Token has not expired"
139+ echo " 3. Token has an expiration date set"
140+ echo " 4. Token has 'repo' and 'workflow' scopes"
141+ echo " 5. Token syntax is correct: "'${{ secrets.TOKEN_NAME }}'"
130142 exit 1
131143 fi
132144 echo "✓ GitHub token is valid and has access to this repository"
You can’t perform that action at this time.
0 commit comments