File tree 1 file changed +35
-0
lines changed
Filter options
1 file changed +35
-0
lines changed
Original file line number Diff line number Diff line change @@ -144,6 +144,41 @@ jobs:
144
144
This will print the full diff object in the screen; `result.data` will
145
145
contain the actual diff text.
146
146
147
+ # ## Run a separate file
148
+
149
+ If you don't want to inline your entire script that you want to run, you can
150
+ use a separate JavaScript file in your repository like so :
151
+
152
+ ` ` ` yaml
153
+ on: push
154
+
155
+ jobs:
156
+ echo-input:
157
+ runs-on: ubuntu-latest
158
+ steps:
159
+ - uses: @actions/github-script@0.9.0
160
+ with:
161
+ script: |
162
+ const path = require('path')
163
+ const scriptPath = path.resolve('./path/to/script.js')
164
+ console.log(require(scriptPath)({context}))
165
+ ` ` `
166
+
167
+ And then export a function from your script :
168
+
169
+ ` ` ` javascript
170
+ module.exports = ({context}) => {
171
+ return context.payload.client_payload.value
172
+ }
173
+ ` ` `
174
+
175
+ You can also use async functions in this manner, as long as you `await` it in
176
+ the inline script.
177
+
178
+ Note that because you can't `require` things like the GitHub context or
179
+ Actions Toolkit libraries, you'll want to pass them as arguments to your
180
+ external script.
181
+
147
182
# ## Result encoding
148
183
149
184
By default, the JSON-encoded return value of the function is set as the "result" in the
You can’t perform that action at this time.
0 commit comments