@@ -257,9 +257,6 @@ module.exports = ({github, context}) => {
257257}
258258` ` `
259259
260- You can also use async functions in this manner, as long as you `await` it in
261- the inline script.
262-
263260Note that because you can't `require` things like the GitHub context or
264261Actions Toolkit libraries, you'll want to pass them as arguments to your
265262external function.
@@ -268,6 +265,44 @@ Additionally, you'll want to use the [checkout
268265action](https://github.com/actions/checkout) to make sure your script file is
269266available.
270267
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+
271306### Use npm packages
272307
273308Like importing your own files above, you can also use installed modules:
0 commit comments