@@ -26,6 +26,36 @@ future versions. 🙂
26
26
27
27
See [ development.md] ( /docs/development.md ) .
28
28
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.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
+
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
+
29
59
# # Examples
30
60
31
61
Note that `github-token` is optional in this action, and the input is there
@@ -141,6 +171,9 @@ jobs:
141
171
console.log(result)
142
172
` ` `
143
173
174
+ See ["Result encoding"](#result-encoding) for details on how the encoding of
175
+ these outputs can be changed.
176
+
144
177
This will print the full diff object in the screen; `result.data` will
145
178
contain the actual diff text.
146
179
@@ -178,22 +211,3 @@ the inline script.
178
211
Note that because you can't `require` things like the GitHub context or
179
212
Actions Toolkit libraries, you'll want to pass them as arguments to your
180
213
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
-
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