Make @actions/core accessible to scripts

This commit is contained in:
Wouter de Vos 2019-10-08 21:19:45 +02:00
parent 47683009b7
commit 62c536d2e0
No known key found for this signature in database
GPG key ID: E6161492628DD4F8
2 changed files with 3 additions and 2 deletions

View file

@ -11,6 +11,7 @@ be provided:
[octokit/rest.js](https://github.com/octokit/rest.js) client
- `context` An object containing the [context of the workflow
run](https://github.com/actions/toolkit/tree/master/packages/github)
- `core` Functions for inputs, outputs, results, logging, secrets and variables from [@actions/core](https://github.com/actions/toolkit/blob/master/packages/core)
Since the `script` is just a function body, these values will already be
defined, so you don't have to (see examples below).

View file

@ -16,8 +16,8 @@ async function main() {
if (previews != null) opts.previews = previews.split(',')
const client = new GitHub(token, opts)
const script = core.getInput('script', {required: true})
const fn = new AsyncFunction('github', 'context', script)
const result = await fn(client, context)
const fn = new AsyncFunction('github', 'context', 'core', script)
const result = await fn(client, context, core)
core.setOutput('result', JSON.stringify(result))
}