Skip to content

Commit d868659

Browse files
fix: validate run_id input for workflow_dispatch and ensure resolved run_id is numeric
Co-authored-by: Copilot <copilot@github.com>
1 parent 0444640 commit d868659

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

.github/workflows/publish-docs.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ jobs:
8181
exit 1
8282
}
8383
84+
if ($env:GITHUB_EVENT_NAME_VALUE -eq 'workflow_dispatch' -and $runId -notmatch '^\d+$') {
85+
Write-Error "Input run_id must be a numeric GitHub Actions run id. Received: '$runId'."
86+
exit 1
87+
}
88+
8489
if ([string]::IsNullOrWhiteSpace($tagName) -or -not $tagName.StartsWith('v')) {
8590
Write-Error "Expected a tag-based workflow run, received '$tagName'."
8691
exit 1
@@ -93,9 +98,14 @@ jobs:
9398
shell: pwsh
9499
env:
95100
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
101+
DOCS_RUN_ID: ${{ steps.context.outputs.run_id }}
96102
run: |
97103
$ErrorActionPreference = 'Stop'
98-
gh run download ${{ steps.context.outputs.run_id }} --name module-docs --dir docs-artifact
104+
if ([string]::IsNullOrWhiteSpace($env:DOCS_RUN_ID) -or $env:DOCS_RUN_ID -notmatch '^\d+$') {
105+
Write-Error "Resolved run id is invalid: '$env:DOCS_RUN_ID'."
106+
exit 1
107+
}
108+
gh run download "$env:DOCS_RUN_ID" --name module-docs --dir docs-artifact
99109
100110
- name: Clone and update homotechsualdocs
101111
shell: pwsh

0 commit comments

Comments
 (0)