Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 181dcc2

Browse files
committed
Add step results section to readme
1 parent 6f0504c commit 181dcc2

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,36 @@ 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/[email protected]
36+
id: set-result
37+
with:
38+
script: return "Hello!"
39+
result-encoding: string
40+
- name: Get result
41+
run: echo "${{steps.my-script.outputs.result}}"
42+
```
43+
44+
## Result encoding
45+
46+
By default, the JSON-encoded return value of the function is set as the "result" in the
47+
output of a github-script step. For some workflows, string encoding is preferred. This option can be set using the
48+
`result-encoding` input:
49+
50+
```yaml
51+
- uses: actions/[email protected]
52+
id: my-script
53+
with:
54+
github-token: ${{secrets.GITHUB_TOKEN}}
55+
result-encoding: string
56+
script: return "I will be string (not JSON) encoded!"
57+
```
58+
2959
## Examples
3060

3161
Note that `github-token` is optional in this action, and the input is there
@@ -141,6 +171,9 @@ jobs:
141171
console.log(result)
142172
```
143173

174+
See ["Result encoding"](#result-encoding) for details on how the encoding of
175+
these outputs can be changed.
176+
144177
This will print the full diff object in the screen; `result.data` will
145178
contain the actual diff text.
146179

@@ -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/[email protected]
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)