mirror of
https://git.mirrors.martin98.com/https://github.com/actions/toolkit
synced 2026-04-01 08:43:21 +08:00
Add support for multi-line secrets in setSecret
This commit is contained in:
@@ -164,6 +164,15 @@ describe('@actions/core', () => {
|
||||
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', () => {
|
||||
const command = 'PATH'
|
||||
createFileCommandFile(command)
|
||||
|
||||
@@ -97,7 +97,11 @@ export function exportVariable(name: string, val: any): void {
|
||||
* @param secret value of the secret
|
||||
*/
|
||||
export function setSecret(secret: string): void {
|
||||
issueCommand('add-mask', {}, secret)
|
||||
secret.split(/\r?\n|\r/).forEach(part => {
|
||||
if (part) {
|
||||
issueCommand('add-mask', {}, part)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user