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
feat(updater): Add SSH key support and comprehensive authentication validation (#134)
* fix(updater): Add token validation and git credential configuration
Addresses GitHub Actions checkout authentication issues by:
- Adding early token validation with clear error messages
- Configuring git credentials explicitly to prevent "terminal prompts disabled" errors
This helps prevent and diagnose common token issues like:
- Expired tokens
- Missing expiration dates
- Insufficient scopes
- Incorrect secret references
Related to actions/checkout#664
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* fix: Escape template expression in error message
* fix(updater): Remove token syntax echo from validation error message
* fix: Improve token validation to detect malformed tokens
* refactor: Use PowerShell for token validation and git config
* feat: Add token scope validation
Checks token scopes using x-oauth-scopes header:
- Reports scopes for classic PATs
- Warns if repo/public_repo scope missing
- Provides guidance for fine-grained PATs
Based on https://github.com/orgs/community/discussions/25259
* fix: Reintroduce token validity and access checks in the validation process
* fix(updater): Remove token syntax echo from validation error message
* feat: Enhance whitespace detection in token validation
Shows detailed information when whitespace is detected:
- Token length
- Position of whitespace character
- Type of whitespace (newline, space, tab, etc)
This helps quickly identify malformed token secrets.
* fix: Remove debug output for token preview in error handling
* 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.
* feat: Add SSH key support as alternative to token authentication
Changes:
- Add ssh-key input parameter
- Make api-token optional when ssh-key is provided
- Pass ssh-key to actions/checkout steps
- Skip token validation when using SSH key
- Skip git credential config when using SSH key
- Validate that only one auth method is provided
This allows the action to work with deploy keys, matching the
functionality of the previous reusable workflow implementation.
Refs: https://github.com/peter-evans/create-pull-request/blob/main/docs/concepts-guidelines.md#push-using-ssh-deploy-keys
* fix: Allow both api-token and ssh-key together
SSH key can be used for git operations while token is used
for GitHub API calls (gh commands, PR creation, etc).
This is a valid and useful configuration.
* 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
* refactor: Remove manual git credential configuration
The actions/checkout action already handles git credential
configuration when token or ssh-key is provided.
Manual configuration was redundant and could potentially
interfere with checkout's credential handling.
* docs: Add changelog entry and update v3 breaking changes
- Add feature and fix entries for SSH key support and authentication validation
- Add note to v3 breaking changes about SSH key support in v3.1
- Reference issue #128 and PR #134
* docs: Remove commented-out api-token option from changelog
* fix: Fallback to github.token when api-token is empty
When using only ssh-key (no api-token), GH_TOKEN was set to empty string,
causing gh CLI to refuse authentication instead of falling back to the
default GITHUB_TOKEN. This broke critical steps that use gh api:
- Parse existing PR URL
- Get changelog
- Update dependency (when filtering by GH release titles)
Changed all instances of:
GH_TOKEN: ${{ inputs.api-token }}
To:
GH_TOKEN: ${{ inputs.api-token || github.token }}
This ensures gh CLI always has valid authentication.
Fixes seer-by-sentry review comment:
#134 (comment)
* fix: Update updater version to use latest stable release
---------
Co-authored-by: Claude <[email protected]>
Copy file name to clipboardExpand all lines: CHANGELOG.md
+23-1Lines changed: 23 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,10 +8,17 @@
8
8
- Scripts receive original and new version as arguments
9
9
- Support both bash (`.sh`) and PowerShell (`.ps1`) scripts
10
10
- Enables workflows like updating lock files, running code generators, or modifying configuration files
11
+
- Updater - Add SSH key support and comprehensive authentication validation ([#134](https://github.com/getsentry/github-workflows/pull/134))
12
+
- Add `ssh-key` input parameter for deploy key authentication
13
+
- Support using both `ssh-key` (for git) and `api-token` (for GitHub API) together
14
+
- Add detailed token validation with actionable error messages
15
+
- Detect common token issues: expiration, whitespace, SSH keys in wrong input, missing scopes
16
+
- Validate SSH key format when provided
11
17
12
18
### Fixes
13
19
14
20
- Updater - Fix boolean input handling for `changelog-entry` parameter and add input validation ([#127](https://github.com/getsentry/github-workflows/pull/127))
21
+
- Updater - Fix cryptic authentication errors with better validation and error messages ([#134](https://github.com/getsentry/github-workflows/pull/134), closes [#128](https://github.com/getsentry/github-workflows/issues/128))
15
22
16
23
### Dependencies
17
24
@@ -52,7 +59,7 @@
52
59
# If a custom token is used instead, a CI would be triggered on a created PR.
53
60
api-token: ${{ secrets.CI_DEPLOY_KEY }}
54
61
55
-
### After
62
+
### After (v3.0)
56
63
native:
57
64
runs-on: ubuntu-latest
58
65
steps:
@@ -63,6 +70,21 @@
63
70
api-token: ${{ secrets.CI_DEPLOY_KEY }}
64
71
```
65
72
73
+
**Note**: If you were using SSH deploy keys with the v2 reusable workflow, the v3.0 composite action initially only supported tokens.
74
+
SSH key support was restored in v3.1 ([#134](https://github.com/getsentry/github-workflows/pull/134)). To use SSH keys, update to v3.1+ and use the `ssh-key` input:
Copy file name to clipboardExpand all lines: updater/action.yml
+126-9Lines changed: 126 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -34,8 +34,13 @@ inputs:
34
34
required: false
35
35
default: ''
36
36
api-token:
37
-
description: 'Token for the repo. Can be passed in using {{ secrets.GITHUB_TOKEN }}'
38
-
required: true
37
+
description: 'Token for the repo. Can be passed in using {{ secrets.GITHUB_TOKEN }}. Not required if ssh-key is provided, but can be used together with ssh-key for GitHub API operations.'
38
+
required: false
39
+
default: ''
40
+
ssh-key:
41
+
description: 'SSH private key for repository authentication. Can be used alone or together with api-token (SSH for git, token for GitHub API).'
42
+
required: false
43
+
default: ''
39
44
post-update-script:
40
45
description: 'Optional script to run after successful dependency update. Can be a bash script (.sh) or PowerShell script (.ps1). The script will be executed in the caller-repo directory before PR creation.'
41
46
required: false
@@ -117,6 +122,116 @@ runs:
117
122
}
118
123
Write-Output "✓ Post-update script path '${{ inputs.post-update-script }}' is valid"
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."
189
+
}
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
+
}
194
+
195
+
# Check token validity and access
196
+
gh api repos/${{ github.repository }} --silent 2>&1 | Out-Null
0 commit comments