Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update docs for setSecret #1430

Merged
merged 3 commits into from
May 25, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion docs/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,18 @@ 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`.

**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 and setSecret commands only support single-line
rentziass marked this conversation as resolved.
Show resolved Hide resolved
secrets or multi-line secrets that have been escaped. `@actions/core`
`setSecret` will escape the string you provide by default. When an escaped
multi-line string is provided the whole string and each of its lines
individually will be masked. For example you can mask `first\nsecond\r\nthird`
using:

```sh
echo "::add-mask::first%0Asecond%0D%0Athird"
```

This will mask `first%0Asecond%0D%0Athird`, `first`, `second` and `third`.

**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`
Expand Down
6 changes: 5 additions & 1 deletion packages/core/__tests__/core.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,11 @@ describe('@actions/core', () => {

it('setSecret produces the correct command', () => {
core.setSecret('secret val')
assertWriteCalls([`::add-mask::secret val${os.EOL}`])
core.setSecret('multi\nline\r\nsecret')
assertWriteCalls([
`::add-mask::secret val${os.EOL}`,
`::add-mask::multi%0Aline%0D%0Asecret${os.EOL}`
])
})

it('prependPath produces the correct commands and sets the env', () => {
Expand Down