@@ -26,6 +26,39 @@ future versions. 🙂
2626
2727See [ 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+ 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+ 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
3164Note that `github-token` is optional in this action, and the input is there
@@ -178,22 +211,3 @@ the inline script.
178211Note that because you can't `require` things like the GitHub context or
179212Actions Toolkit libraries, you'll want to pass them as arguments to your
180213external 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- 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