-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
only print secret keys in build summary output
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
- Loading branch information
CrazyMax
committed
Apr 9, 2025
1 parent
548776e
commit 094d2bc
Showing
3 changed files
with
42 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,58 @@ | ||
import * as core from '@actions/core'; | ||
|
||
import {Inputs, sanitizeInputs} from './context'; | ||
import {Build} from '@docker/actions-toolkit/lib/buildx/build'; | ||
|
||
import {Inputs} from './context'; | ||
|
||
export const tmpDir = process.env['STATE_tmpDir'] || ''; | ||
export const inputs = process.env['STATE_inputs'] ? JSON.parse(process.env['STATE_inputs']) : undefined; | ||
export const buildRef = process.env['STATE_buildRef'] || ''; | ||
export const isSummarySupported = !!process.env['STATE_isSummarySupported']; | ||
export const summaryInputs = process.env['STATE_summaryInputs'] ? JSON.parse(process.env['STATE_summaryInputs']) : undefined; | ||
|
||
export function setTmpDir(tmpDir: string) { | ||
core.saveState('tmpDir', tmpDir); | ||
} | ||
|
||
export function setInputs(inputs: Inputs) { | ||
core.saveState('inputs', JSON.stringify(sanitizeInputs(inputs))); | ||
} | ||
|
||
export function setBuildRef(buildRef: string) { | ||
core.saveState('buildRef', buildRef); | ||
} | ||
|
||
export function setSummarySupported() { | ||
core.saveState('isSummarySupported', 'true'); | ||
} | ||
|
||
export function setSummaryInputs(inputs: Inputs) { | ||
const res = {}; | ||
for (const key of Object.keys(inputs)) { | ||
if (key === 'github-token') { | ||
continue; | ||
} | ||
const value: string | string[] | boolean = inputs[key]; | ||
if (typeof value === 'boolean' && !value) { | ||
continue; | ||
} else if (Array.isArray(value)) { | ||
if (value.length === 0) { | ||
continue; | ||
} else if (key === 'secrets' && value.length > 0) { | ||
const secretKeys: string[] = []; | ||
for (const secret of value) { | ||
try { | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
const [skey, _] = Build.parseSecretKvp(secret, true); | ||
secretKeys.push(skey); | ||
} catch (err) { | ||
// ignore invalid secret | ||
} | ||
} | ||
if (secretKeys.length > 0) { | ||
res[key] = secretKeys; | ||
} | ||
continue; | ||
} | ||
} else if (!value) { | ||
continue; | ||
} | ||
res[key] = value; | ||
} | ||
core.saveState('summaryInputs', JSON.stringify(res)); | ||
} |