-
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.
Merge pull request #1353 from crazy-max/summary-secret-keys
only print secret keys in build summary output
- Loading branch information
Showing
5 changed files
with
44 additions
and
29 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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)); | ||
} |