mirror of https://github.com/actions/toolkit
Add support for multi-line secrets in setSecret
parent
37e09c586f
commit
5ccbd5f448
|
@ -50,7 +50,10 @@ function setSecret(secret: string): void {}
|
||||||
|
|
||||||
Now, future logs containing BAR will be masked. E.g. running `echo "Hello FOO BAR World"` will now print `Hello FOO **** World`.
|
Now, future logs containing BAR will be masked. E.g. running `echo "Hello FOO BAR World"` will now print `Hello FOO **** World`.
|
||||||
|
|
||||||
**WARNING** The add-mask and setSecret commands only support single line secrets. To register a multiline secrets you must register each line individually otherwise it will not be masked.
|
**WARNING** The add-mask command only supports single line secrets. To register
|
||||||
|
a multiline secret you must register each line individually otherwise it will
|
||||||
|
not be masked, if you use `@actions/core >= 1.11.0` `setSecret` will do this
|
||||||
|
for you.
|
||||||
|
|
||||||
**WARNING** Do **not** mask short values if you can avoid it, it could render your output unreadable (and future steps' output as well).
|
**WARNING** Do **not** mask short values if you can avoid it, it could render your output unreadable (and future steps' output as well).
|
||||||
For example, if you mask the letter `l`, running `echo "Hello FOO BAR World"` will now print `He*********o FOO BAR Wor****d`
|
For example, if you mask the letter `l`, running `echo "Hello FOO BAR World"` will now print `He*********o FOO BAR Wor****d`
|
||||||
|
|
|
@ -164,6 +164,15 @@ describe('@actions/core', () => {
|
||||||
assertWriteCalls([`::add-mask::secret val${os.EOL}`])
|
assertWriteCalls([`::add-mask::secret val${os.EOL}`])
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('setSecret splits multi line secrets into multiple commands', () => {
|
||||||
|
core.setSecret('first\nsecond\r\nthird')
|
||||||
|
assertWriteCalls([
|
||||||
|
`::add-mask::first${os.EOL}`,
|
||||||
|
`::add-mask::second${os.EOL}`,
|
||||||
|
`::add-mask::third${os.EOL}`
|
||||||
|
])
|
||||||
|
})
|
||||||
|
|
||||||
it('prependPath produces the correct commands and sets the env', () => {
|
it('prependPath produces the correct commands and sets the env', () => {
|
||||||
const command = 'PATH'
|
const command = 'PATH'
|
||||||
createFileCommandFile(command)
|
createFileCommandFile(command)
|
||||||
|
|
|
@ -97,7 +97,11 @@ export function exportVariable(name: string, val: any): void {
|
||||||
* @param secret value of the secret
|
* @param secret value of the secret
|
||||||
*/
|
*/
|
||||||
export function setSecret(secret: string): void {
|
export function setSecret(secret: string): void {
|
||||||
issueCommand('add-mask', {}, secret)
|
secret.split(/\r?\n|\r/).forEach(part => {
|
||||||
|
if (part) {
|
||||||
|
issueCommand('add-mask', {}, part)
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue