Skip to content

Commit 1ff65db

Browse files
committed
fix: mask vercel token in logs, sanitize commit metadata, and preserve retry error context
- Add core.setSecret(vercelToken) to prevent token leakage in action logs - Sanitize commit message (strip newlines/quotes) before passing as metadata - Preserve original error output when retry path also fails - Remove core.exportVariable for VERCEL_ORG_ID (process.env delete suffices)
1 parent 3c74304 commit 1ff65db

2 files changed

Lines changed: 18 additions & 4 deletions

File tree

dist/index.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59652,6 +59652,7 @@ function getVercelBin() {
5965259652
}
5965359653

5965459654
const vercelToken = core.getInput('vercel-token', { required: true })
59655+
core.setSecret(vercelToken)
5965559656
const vercelArgs = core.getInput('vercel-args')
5965659657
const vercelOrgId = core.getInput('vercel-org-id')
5965759658
const vercelProjectId = core.getInput('vercel-project-id')
@@ -59745,7 +59746,7 @@ function buildDeployArgs(providedArgs, ref, commit, sha, commitOrg, commitRepo)
5974559746
...addVercelMetadata('githubRepo', context.repo.repo, providedArgs),
5974659747
...addVercelMetadata('githubCommitOrg', commitOrg, providedArgs),
5974759748
...addVercelMetadata('githubCommitRepo', commitRepo, providedArgs),
59748-
...addVercelMetadata('githubCommitMessage', `"${commit}"`, providedArgs),
59749+
...addVercelMetadata('githubCommitMessage', `"${commit.replace(/[\r\n]+/g, ' ').replace(/"/g, '')}"`, providedArgs),
5974959750
...addVercelMetadata(
5975059751
'githubCommitRef',
5975159752
ref.replace('refs/heads/', ''),
@@ -59799,15 +59800,21 @@ async function vercelDeploy(ref, commit, sha, commitOrg, commitRepo) {
5979959800
'Vercel CLI rejected the org ID as a personal account scope. '
5980059801
+ 'Retrying without VERCEL_ORG_ID (VERCEL_PROJECT_ID is still set).',
5980159802
)
59802-
core.exportVariable('VERCEL_ORG_ID', '')
5980359803
delete process.env.VERCEL_ORG_ID
5980459804

59805+
const originalOutput = myOutput
59806+
const originalError = myError
5980559807
myOutput = ''
5980659808
myError = ''
5980759809
const retryArgs = buildDeployArgs(providedArgs, ref, commit, sha, commitOrg, commitRepo)
5980859810
// Don't re-add --scope on retry — it may have caused the personal account error
5980959811

5981059812
exitCode = await exec.exec('npx', [vercelBin, ...retryArgs], options)
59813+
59814+
if (exitCode !== 0) {
59815+
core.error(`Original attempt output:\n${originalOutput}`)
59816+
core.error(`Original attempt errors:\n${originalError}`)
59817+
}
5981159818
}
5981259819

5981359820
if (exitCode !== 0) {

index.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ function getVercelBin() {
6767
}
6868

6969
const vercelToken = core.getInput('vercel-token', { required: true })
70+
core.setSecret(vercelToken)
7071
const vercelArgs = core.getInput('vercel-args')
7172
const vercelOrgId = core.getInput('vercel-org-id')
7273
const vercelProjectId = core.getInput('vercel-project-id')
@@ -160,7 +161,7 @@ function buildDeployArgs(providedArgs, ref, commit, sha, commitOrg, commitRepo)
160161
...addVercelMetadata('githubRepo', context.repo.repo, providedArgs),
161162
...addVercelMetadata('githubCommitOrg', commitOrg, providedArgs),
162163
...addVercelMetadata('githubCommitRepo', commitRepo, providedArgs),
163-
...addVercelMetadata('githubCommitMessage', `"${commit}"`, providedArgs),
164+
...addVercelMetadata('githubCommitMessage', `"${commit.replace(/[\r\n]+/g, ' ').replace(/"/g, '')}"`, providedArgs),
164165
...addVercelMetadata(
165166
'githubCommitRef',
166167
ref.replace('refs/heads/', ''),
@@ -214,15 +215,21 @@ async function vercelDeploy(ref, commit, sha, commitOrg, commitRepo) {
214215
'Vercel CLI rejected the org ID as a personal account scope. '
215216
+ 'Retrying without VERCEL_ORG_ID (VERCEL_PROJECT_ID is still set).',
216217
)
217-
core.exportVariable('VERCEL_ORG_ID', '')
218218
delete process.env.VERCEL_ORG_ID
219219

220+
const originalOutput = myOutput
221+
const originalError = myError
220222
myOutput = ''
221223
myError = ''
222224
const retryArgs = buildDeployArgs(providedArgs, ref, commit, sha, commitOrg, commitRepo)
223225
// Don't re-add --scope on retry — it may have caused the personal account error
224226

225227
exitCode = await exec.exec('npx', [vercelBin, ...retryArgs], options)
228+
229+
if (exitCode !== 0) {
230+
core.error(`Original attempt output:\n${originalOutput}`)
231+
core.error(`Original attempt errors:\n${originalError}`)
232+
}
226233
}
227234

228235
if (exitCode !== 0) {

0 commit comments

Comments
 (0)