Skip to content

Commit

Permalink
Merge pull request #50 from actions/readme-update
Browse files Browse the repository at this point in the history
Add step results section to readme
  • Loading branch information
jclem authored May 18, 2020
2 parents 6f0504c + dd16c14 commit e16145c
Showing 1 changed file with 33 additions and 19 deletions.
52 changes: 33 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,39 @@ future versions. 🙂

See [development.md](/docs/development.md).

## Reading step results

The return value of the script will be in the step's outputs under the
"result" key.

```yaml
- uses: actions/[email protected]
id: set-result
with:
script: return "Hello!"
result-encoding: string
- name: Get result
run: echo "${{steps.set-result.outputs.result}}"
```
See ["Result encoding"](#result-encoding) for details on how the encoding of
these outputs can be changed.
## Result encoding
By default, the JSON-encoded return value of the function is set as the "result" in the
output of a github-script step. For some workflows, string encoding is preferred. This option can be set using the
`result-encoding` input:

```yaml
- uses: actions/[email protected]
id: my-script
with:
github-token: ${{secrets.GITHUB_TOKEN}}
result-encoding: string
script: return "I will be string (not JSON) encoded!"
```

## Examples

Note that `github-token` is optional in this action, and the input is there
Expand Down Expand Up @@ -178,22 +211,3 @@ the inline script.
Note that because you can't `require` things like the GitHub context or
Actions Toolkit libraries, you'll want to pass them as arguments to your
external function.

### Result encoding

By default, the JSON-encoded return value of the function is set as the "result" in the
output of a github-script step. For some workflows, string encoding is preferred. This option can be set using the
`result-encoding` input:

```yaml
- uses: actions/[email protected]
id: my-script
with:
github-token: ${{secrets.GITHUB_TOKEN}}
result-encoding: string
script: |
return "I will be string (not JSON) encoded!"
- name: Prints result
run: cat '${{ steps.my-script.outputs.result }}'
```

0 comments on commit e16145c

Please sign in to comment.