You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor: Split authentication validation into separate steps
Changes:
- Step 1: Validate authentication inputs (checks at least one is present)
- Step 2: Validate API token (runs only if token provided)
- Step 3: Validate SSH key (runs only if SSH key provided)
Benefits:
- Clearer separation of concerns
- Easier to read and maintain
- Each validation only runs when relevant
- SSH key validation now checks format
Write-Output "::warning::Token has no scopes. If using a fine-grained PAT, ensure it has Contents (write) and Pull Requests (write) permissions."
185
+
} else {
186
+
Write-Output "Token scopes: $scopes"
187
+
if ($scopes -notmatch '\brepo\b' -and $scopes -notmatch '\bpublic_repo\b') {
188
+
Write-Output "::warning::Token may be missing 'repo' or 'public_repo' scope. This may cause issues with private repositories."
162
189
}
163
-
Write-Output "::error::GitHub token contains whitespace at position $position of $tokenLength characters: $charName"
164
-
Write-Output "::error::This suggests the token secret may be malformed. Check for extra newlines when setting the secret."
165
-
exit 1
166
190
}
191
+
} else {
192
+
Write-Output "::notice::Could not detect token scopes (this is normal for fine-grained PATs). Ensure token has Contents (write) and Pull Requests (write) permissions."
193
+
}
167
194
168
-
# Check token scopes (works for classic PATs only)
Write-Output "::warning::Token has no scopes. If using a fine-grained PAT, ensure it has Contents (write) and Pull Requests (write) permissions."
175
-
} else {
176
-
Write-Output "Token scopes: $scopes"
177
-
if ($scopes -notmatch '\brepo\b' -and $scopes -notmatch '\bpublic_repo\b') {
178
-
Write-Output "::warning::Token may be missing 'repo' or 'public_repo' scope. This may cause issues with private repositories."
179
-
}
180
-
}
181
-
} else {
182
-
Write-Output "::notice::Could not detect token scopes (this is normal for fine-grained PATs). Ensure token has Contents (write) and Pull Requests (write) permissions."
183
-
}
195
+
# Check token validity and access
196
+
gh api repos/${{ github.repository }} --silent 2>&1 | Out-Null
0 commit comments