diff --git a/packages/core/README.md b/packages/core/README.md index 58a8287f..860dce3d 100644 --- a/packages/core/README.md +++ b/packages/core/README.md @@ -4,45 +4,51 @@ ## Usage -#### Inputs/Outputs - -You can use this library to get inputs or set outputs: +### Import the package ```js +// javascript const core = require('@actions/core'); -const myInput = core.getInput('inputName', { required: true }); +// typescript +import * as core from '@actions/core'; +``` -// Do stuff +#### Inputs/Outputs + +Action inputs can be read with `getInput`. Outputs can be set with `setOutput` which makes them available to be mapped into inputs of other actions to ensure they are decoupled. + +```js +const myInput = core.getInput('inputName', { required: true }); core.setOutput('outputKey', 'outputVal'); ``` #### Exporting variables -You can also export variables for future steps. Variables get set in the environment. +Since each step runs in a separate process, you can use `exportVariable` to add it to this step and future steps environment blocks. ```js -const core = require('@actions/core'); - -// Do stuff - 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. + +```js +core.exportSecret('myPassword', mypass); +``` + #### PATH Manipulation -You can explicitly add items to the path for all remaining steps in a workflow: +To make a tool's path available in the path for the remainder of the job (without altering the machine or containers state), use `addPath`. The runner will prepend the path given to the jobs PATH. ```js -const core = require('@actions/core'); - -core.addPath('pathToTool'); +core.addPath('/path/to/mytool'); ``` #### Exit codes -You should use this library to set the failing exit code for your action: +You should use this library to set the failing exit code for your action. If status is not set and the script runs to completion, that will lead to a success. ```js const core = require('@actions/core'); @@ -55,6 +61,8 @@ catch (err) { core.setFailed(`Action failed with error ${err}`); } +Note that `setNeutral` is not yet implemented in actions V2 but equivalent functionality is being planned. + ``` #### Logging diff --git a/packages/core/RELEASES.md b/packages/core/RELEASES.md index 8a0bf426..d677f69a 100644 --- a/packages/core/RELEASES.md +++ b/packages/core/RELEASES.md @@ -1,8 +1,11 @@ # @actions/core Releases +### 1.1.2 + +- set-secret is now available for use [#141](https://github.com/actions/toolkit/issues/141) + ### 1.1.1 -- set-secret is now available for use [#141](https://github.com/actions/toolkit/issues/141) - Add support for action input variables with multiple spaces [#127](https://github.com/actions/toolkit/issues/127) - Switched ## commands to :: commands (should have no noticeable impact) [#110)(https://github.com/actions/toolkit/pull/110) diff --git a/packages/core/__tests__/lib.test.ts b/packages/core/__tests__/lib.test.ts index 0bbe43d8..75bb04c7 100644 --- a/packages/core/__tests__/lib.test.ts +++ b/packages/core/__tests__/lib.test.ts @@ -125,11 +125,6 @@ describe('@actions/core', () => { assertWriteCalls([`::set-output name=some output,::some value${os.EOL}`]) }) - it('setNeutral sets the correct exit code', () => { - core.setFailed('Failure message') - expect(process.exitCode).toBe(core.ExitCode.Failure) - }) - it('setFailure sets the correct exit code and failure message', () => { core.setFailed('Failure message') expect(process.exitCode).toBe(core.ExitCode.Failure) diff --git a/packages/core/package.json b/packages/core/package.json index 151fbee4..bad955bf 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@actions/core", - "version": "1.1.1", + "version": "1.1.2", "description": "Actions core lib", "keywords": [ "github",