Skip to content

Commit 02e7c4f

Browse files
committed
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)
1 parent 8e9eef8 commit 02e7c4f

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

updater/action.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ runs:
125125
- name: Validate authentication inputs
126126
shell: pwsh
127127
env:
128-
GH_TOKEN: ${{ inputs.api-token }}
128+
GH_TOKEN: ${{ inputs.api-token || github.token }}
129129
SSH_KEY: ${{ inputs.ssh-key }}
130130
run: |
131131
$hasToken = -not [string]::IsNullOrEmpty($env:GH_TOKEN)
@@ -148,7 +148,7 @@ runs:
148148
if: ${{ inputs.api-token != '' }}
149149
shell: pwsh
150150
env:
151-
GH_TOKEN: ${{ inputs.api-token }}
151+
GH_TOKEN: ${{ inputs.api-token || github.token }}
152152
run: |
153153
# Check if token is actually an SSH key
154154
if ($env:GH_TOKEN -match '-----BEGIN') {
@@ -266,7 +266,7 @@ runs:
266266
DEPENDENCY_PATTERN: ${{ inputs.pattern }}
267267
GH_TITLE_PATTERN: ${{ inputs.gh-title-pattern }}
268268
POST_UPDATE_SCRIPT: ${{ inputs.post-update-script }}
269-
GH_TOKEN: ${{ inputs.api-token }}
269+
GH_TOKEN: ${{ inputs.api-token || github.token }}
270270
run: ${{ github.action_path }}/scripts/update-dependency.ps1 -Path $env:DEPENDENCY_PATH -Pattern $env:DEPENDENCY_PATTERN -GhTitlePattern $env:GH_TITLE_PATTERN -PostUpdateScript $env:POST_UPDATE_SCRIPT
271271

272272
- name: Get the base repo info
@@ -310,7 +310,7 @@ runs:
310310
shell: pwsh
311311
working-directory: caller-repo
312312
env:
313-
GH_TOKEN: ${{ inputs.api-token }}
313+
GH_TOKEN: ${{ inputs.api-token || github.token }}
314314
run: |
315315
$urls = @(gh api 'repos/${{ github.repository }}/pulls?base=${{ steps.root.outputs.baseBranch }}&head=${{ github.repository_owner }}:${{ steps.root.outputs.prBranch }}' --jq '.[].html_url')
316316
if ($urls.Length -eq 0)
@@ -337,7 +337,7 @@ runs:
337337
shell: pwsh
338338
working-directory: caller-repo
339339
env:
340-
GH_TOKEN: ${{ inputs.api-token }}
340+
GH_TOKEN: ${{ inputs.api-token || github.token }}
341341
run: |
342342
$changelog = ${{ github.action_path }}/scripts/get-changelog.ps1 `
343343
-RepoUrl '${{ steps.target.outputs.url }}' `
@@ -404,7 +404,7 @@ runs:
404404
env:
405405
DEPENDENCY_PATH: ${{ inputs.path }}
406406
POST_UPDATE_SCRIPT: ${{ inputs.post-update-script }}
407-
GH_TOKEN: ${{ inputs.api-token }}
407+
GH_TOKEN: ${{ inputs.api-token || github.token }}
408408
run: ${{ github.action_path }}/scripts/update-dependency.ps1 -Path $env:DEPENDENCY_PATH -Tag '${{ steps.target.outputs.latestTag }}' -OriginalTag '${{ steps.target.outputs.originalTag }}' -PostUpdateScript $env:POST_UPDATE_SCRIPT
409409

410410
- name: Update Changelog
@@ -414,7 +414,7 @@ runs:
414414
env:
415415
DEPENDENCY_NAME: ${{ inputs.name }}
416416
CHANGELOG_SECTION: ${{ inputs.changelog-section }}
417-
GH_TOKEN: ${{ inputs.api-token }}
417+
GH_TOKEN: ${{ inputs.api-token || github.token }}
418418
run: |
419419
${{ github.action_path }}/scripts/update-changelog.ps1 `
420420
-Name $env:DEPENDENCY_NAME `

0 commit comments

Comments
 (0)