Skip to content

Commit 9333c40

Browse files
committed
feat: Add explicit check for SSH keys in token validation
Detects when an SSH private key is mistakenly passed as api-token. Provides clear error message explaining the difference between SSH keys and GitHub tokens. This catches the error before the generic whitespace check.
1 parent 9e13f1c commit 9333c40

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

updater/action.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,13 @@ runs:
127127
exit 1
128128
}
129129
130+
if ($env:GH_TOKEN -match '-----BEGIN') {
131+
Write-Output "::error::The provided token appears to be an SSH private key, not a GitHub token."
132+
Write-Output "::error::The api-token input requires a GitHub Personal Access Token (PAT) or GITHUB_TOKEN."
133+
Write-Output "::error::SSH keys should be configured separately using deploy keys or ssh-key inputs."
134+
exit 1
135+
}
136+
130137
if ($env:GH_TOKEN -match '\s') {
131138
$tokenLength = $env:GH_TOKEN.Length
132139
$whitespaceMatch = [regex]::Match($env:GH_TOKEN, '\s')
@@ -141,9 +148,6 @@ runs:
141148
}
142149
Write-Output "::error::GitHub token contains whitespace at position $position of $tokenLength characters: $charName"
143150
Write-Output "::error::This suggests the token secret may be malformed. Check for extra newlines when setting the secret."
144-
# XXX remove
145-
$preview = $env:GH_TOKEN.Substring(5, 10)
146-
Write-Output "Token around the error: $preview"
147151
exit 1
148152
}
149153

0 commit comments

Comments
 (0)