@@ -257,9 +257,6 @@ module.exports = ({github, context}) => {
257
257
}
258
258
` ` `
259
259
260
- You can also use async functions in this manner, as long as you `await` it in
261
- the inline script.
262
-
263
260
Note that because you can't `require` things like the GitHub context or
264
261
Actions Toolkit libraries, you'll want to pass them as arguments to your
265
262
external function.
@@ -268,6 +265,44 @@ Additionally, you'll want to use the [checkout
268
265
action](https://github.com/actions/checkout) to make sure your script file is
269
266
available.
270
267
268
+ # ## Run a separate file with an async function
269
+
270
+ You can also use async functions in this manner, as long as you `await` it in
271
+ the inline script.
272
+
273
+ In your workflow :
274
+
275
+ ` ` ` yaml
276
+ on: push
277
+
278
+ jobs:
279
+ echo-input:
280
+ runs-on: ubuntu-latest
281
+ steps:
282
+ - uses: actions/checkout@v2
283
+ - uses: actions/github-script@v3
284
+ env:
285
+ SHA: "${{env.parentSHA}}"
286
+ with:
287
+ script: |
288
+ const script = require(` ${process.env.GITHUB_WORKSPACE}/path/to/script.js`)
289
+ await script({github, context, core})
290
+ ```
291
+
292
+ And then export an async function from your module:
293
+
294
+ ``` javascript
295
+ module .exports = async ({ github, context, core }) => {
296
+ const { SHA } = process .env
297
+ const commit = await github .repos .getCommit ({
298
+ owner: context .repo .owner ,
299
+ repo: context .repo .repo ,
300
+ ref: ` ${ SHA } `
301
+ })
302
+ core .exportVariable (' author' , commit .data .commit .author .email );
303
+ }
304
+ ```
305
+
271
306
### Use npm packages
272
307
273
308
Like importing your own files above, you can also use installed modules:
0 commit comments