Skip to content

Commit e16145c

Browse files
authored
Merge pull request #50 from actions/readme-update
Add step results section to readme
2 parents 6f0504c + dd16c14 commit e16145c

File tree

1 file changed

+33
-19
lines changed

1 file changed

+33
-19
lines changed

README.md

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,39 @@ future versions. 🙂
2626

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

29+
## Reading step results
30+
31+
The return value of the script will be in the step's outputs under the
32+
"result" key.
33+
34+
```yaml
35+
- uses: actions/github-script@0.9.0
36+
id: set-result
37+
with:
38+
script: return "Hello!"
39+
result-encoding: string
40+
- name: Get result
41+
run: echo "${{steps.set-result.outputs.result}}"
42+
```
43+
44+
See ["Result encoding"](#result-encoding) for details on how the encoding of
45+
these outputs can be changed.
46+
47+
## Result encoding
48+
49+
By default, the JSON-encoded return value of the function is set as the "result" in the
50+
output of a github-script step. For some workflows, string encoding is preferred. This option can be set using the
51+
`result-encoding` input:
52+
53+
```yaml
54+
- uses: actions/github-script@0.9.0
55+
id: my-script
56+
with:
57+
github-token: ${{secrets.GITHUB_TOKEN}}
58+
result-encoding: string
59+
script: return "I will be string (not JSON) encoded!"
60+
```
61+
2962
## Examples
3063

3164
Note that `github-token` is optional in this action, and the input is there
@@ -178,22 +211,3 @@ the inline script.
178211
Note that because you can't `require` things like the GitHub context or
179212
Actions Toolkit libraries, you'll want to pass them as arguments to your
180213
external function.
181-
182-
### Result encoding
183-
184-
By default, the JSON-encoded return value of the function is set as the "result" in the
185-
output of a github-script step. For some workflows, string encoding is preferred. This option can be set using the
186-
`result-encoding` input:
187-
188-
```yaml
189-
- uses: actions/github-script@0.9.0
190-
id: my-script
191-
with:
192-
github-token: ${{secrets.GITHUB_TOKEN}}
193-
result-encoding: string
194-
script: |
195-
return "I will be string (not JSON) encoded!"
196-
197-
- name: Prints result
198-
run: cat '${{ steps.my-script.outputs.result }}'
199-
```

0 commit comments

Comments
 (0)