diff --git a/docs/commands.md b/docs/commands.md index 6fa657f7..5af0787e 100644 --- a/docs/commands.md +++ b/docs/commands.md @@ -67,15 +67,16 @@ export function setOutput(name: string, value: string): void {} If a script or action does work to create a secret at runtime, it can be registered with the runner to be masked in logs. -To mask a value in the logs, use `::set-secret`: +To mask a value in the logs, use `::add-mask`: ```sh -echo ::set-secret::BAR +echo ::add-mask::mysecretvalue ``` -This is wrapped by the core method which both sets the value as a variable for future steps and registers the secret to mask +This is wrapped by the core setSecret method + ```javascript -function exportSecret(name: string, val: string): void {} +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`. diff --git a/packages/core/README.md b/packages/core/README.md index 860dce3d..026bb520 100644 --- a/packages/core/README.md +++ b/packages/core/README.md @@ -32,10 +32,12 @@ Since each step runs in a separate process, you can use `exportVariable` to add core.exportVariable('envVar', 'Val'); ``` -Exporting a secret exports the variable but also registers the secret with the runner to ensure it is masked in logs. +#### Setting a secret + +Setting a secret registers the secret with the runner to ensure it is masked in logs. ```js -core.exportSecret('myPassword', mypass); +core.setSecret('myPassword'); ``` #### PATH Manipulation diff --git a/packages/core/RELEASES.md b/packages/core/RELEASES.md index d677f69a..48f58a2b 100644 --- a/packages/core/RELEASES.md +++ b/packages/core/RELEASES.md @@ -1,8 +1,9 @@ # @actions/core Releases -### 1.1.2 +### 1.1.3 -- set-secret is now available for use [#141](https://github.com/actions/toolkit/issues/141) +- setSecret added to register a secret with the runner to be masked from the logs +- exportSecret which was not implemented and never worked was removed after clarification from product. ### 1.1.1 diff --git a/packages/core/__tests__/lib.test.ts b/packages/core/__tests__/lib.test.ts index 75bb04c7..838f23b8 100644 --- a/packages/core/__tests__/lib.test.ts +++ b/packages/core/__tests__/lib.test.ts @@ -51,34 +51,10 @@ describe('@actions/core', () => { assertWriteCalls([`::set-env name=my var2,::var val%0D%0A${os.EOL}`]) }) - // it('exportSecret produces the correct commands and sets the env', () => { - // core.exportSecret('my secret', 'secret val') - // expect(process.env['my secret']).toBe('secret val') - // assertWriteCalls([ - // `::set-env name=my secret,::secret val${os.EOL}`, - // `::set-secret]secret val${os.EOL}` - // ]) - // }) - - // it('exportSecret escapes secret names', () => { - // core.exportSecret('special char secret \r\n];', 'special secret val') - // expect(process.env['special char secret \r\n];']).toBe('special secret val') - // assertWriteCalls([ - // `::set-env name=special char secret %0D%0A%5D%3B,::special secret val${ - // os.EOL - // }`, - // `::set-secret]special secret val${os.EOL}` - // ]) - // }) - - // it('exportSecret escapes secret values', () => { - // core.exportSecret('my secret2', 'secret val\r\n') - // expect(process.env['my secret2']).toBe('secret val\r\n') - // assertWriteCalls([ - // `::set-env name=my secret2,::secret val%0D%0A${os.EOL}`, - // `::set-secret]secret val%0D%0A${os.EOL}` - // ]) - // }) + it('setSecret produces the correct command', () => { + core.setSecret('secret val') + assertWriteCalls([`::add-mask::secret val${os.EOL}`]) + }) it('prependPath produces the correct commands and sets the env', () => { core.addPath('myPath') diff --git a/packages/core/package.json b/packages/core/package.json index bad955bf..a08bded8 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@actions/core", - "version": "1.1.2", + "version": "1.1.3", "description": "Actions core lib", "keywords": [ "github", diff --git a/packages/core/src/core.ts b/packages/core/src/core.ts index 072f2323..000cdd7a 100644 --- a/packages/core/src/core.ts +++ b/packages/core/src/core.ts @@ -31,7 +31,7 @@ export enum ExitCode { //----------------------------------------------------------------------- /** - * sets env variable for this action and future actions in the job + * Sets env variable for this action and future actions in the job * @param name the name of the variable to set * @param val the value of the variable */ @@ -41,16 +41,11 @@ export function exportVariable(name: string, val: string): void { } /** - * exports the variable and registers a secret which will get masked from logs - * @param name the name of the variable to set - * @param val value of the secret + * Registers a secret which will get masked from logs + * @param secret value of the secret */ -export function exportSecret(name: string, val: string): void { - exportVariable(name, val) - - // the runner will error with not implemented - // leaving the function but raising the error earlier - issueCommand('set-secret', {}, val) +export function setSecret(secret: string): void { + issueCommand('add-mask', {}, secret) } /**