1
0
Fork 0

updating core docs and bumping version (#172)

updating core docs and bumping version
pull/177/head
Bryan MacFarlane 2019-10-01 13:53:09 -04:00 committed by GitHub
parent 05b1b08f77
commit 713902387e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 28 additions and 22 deletions

View File

@ -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

View File

@ -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)

View File

@ -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)

View File

@ -1,6 +1,6 @@
{
"name": "@actions/core",
"version": "1.1.1",
"version": "1.1.2",
"description": "Actions core lib",
"keywords": [
"github",