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: 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
Copy file name to clipboardExpand all lines: updater/action.yml
+71-50Lines changed: 71 additions & 50 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.'
38
+
required: false
39
+
default: ''
40
+
ssh-key:
41
+
description: 'SSH private key for repository authentication. Alternative to api-token. Use for deploy key authentication.'
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,71 +122,85 @@ runs:
117
122
}
118
123
Write-Output "✓ Post-update script path '${{ inputs.post-update-script }}' is valid"
119
124
120
-
- name: Validate GitHub token
125
+
- name: Validate authentication
121
126
shell: pwsh
122
127
env:
123
128
GH_TOKEN: ${{ inputs.api-token }}
129
+
SSH_KEY: ${{ inputs.ssh-key }}
124
130
run: |
125
-
if ([string]::IsNullOrEmpty($env:GH_TOKEN)) {
126
-
Write-Output "::error::GitHub token is empty. Please verify the token is passed correctly."
default { "whitespace character (code: $([int][char]$char))" }
165
163
}
164
+
Write-Output "::error::GitHub token contains whitespace at position $position of $tokenLength characters: $charName"
165
+
Write-Output "::error::This suggests the token secret may be malformed. Check for extra newlines when setting the secret."
166
+
exit 1
166
167
}
167
-
} else {
168
-
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."
169
-
}
170
168
171
-
# Check token validity and access
172
-
gh api repos/${{ github.repository }} --silent 2>&1 | Out-Null
Write-Output "::warning::Token has no scopes. If using a fine-grained PAT, ensure it has Contents (write) and Pull Requests (write) permissions."
176
+
} else {
177
+
Write-Output "Token scopes: $scopes"
178
+
if ($scopes -notmatch '\brepo\b' -and $scopes -notmatch '\bpublic_repo\b') {
179
+
Write-Output "::warning::Token may be missing 'repo' or 'public_repo' scope. This may cause issues with private repositories."
180
+
}
181
+
}
182
+
} else {
183
+
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."
184
+
}
181
185
182
-
Write-Output "✓ GitHub token is valid and has access to this repository"
186
+
# Check token validity and access
187
+
gh api repos/${{ github.repository }} --silent 2>&1 | Out-Null
0 commit comments