From 89821567830f4c34879b6fa18388b5c81da80cec Mon Sep 17 00:00:00 2001 From: Jonathan Clem Date: Tue, 24 Mar 2020 13:57:27 -0400 Subject: [PATCH 1/3] Add core to the script context --- dist/index.js | 2 +- src/main.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index 68a5dc52c..5d7c55b64 100644 --- a/dist/index.js +++ b/dist/index.js @@ -9178,7 +9178,7 @@ async function main() { const github = new lib_github.GitHub(token, opts); const script = Object(core.getInput)('script', { required: true }); // Using property/value shorthand on `require` (e.g. `{require}`) causes compilatin errors. - const result = await callAsyncFunction({ require: __webpack_require__(875), github, context: lib_github.context }, script); + const result = await callAsyncFunction({ require: __webpack_require__(875), github, context: lib_github.context, core: core }, script); let encoding = Object(core.getInput)('result-encoding'); encoding = encoding ? encoding : 'json'; let output; diff --git a/src/main.ts b/src/main.ts index 89bf9e4fe..00e95a1fe 100644 --- a/src/main.ts +++ b/src/main.ts @@ -19,7 +19,7 @@ async function main() { // Using property/value shorthand on `require` (e.g. `{require}`) causes compilatin errors. const result = await callAsyncFunction( - {require: require, github, context}, + {require: require, github, context, core}, script ) From dc16f26602aabf8eacfc4e732b7fc4df1a507235 Mon Sep 17 00:00:00 2001 From: Jonathan Clem Date: Tue, 24 Mar 2020 14:02:45 -0400 Subject: [PATCH 2/3] Add core to integration test --- .github/workflows/integration.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 2cfc8827e..b43f4e766 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -8,9 +8,10 @@ jobs: - id: output-set uses: actions/github-script@master with: - script: return 'test' + script: return core.getInput('input-value') result-encoding: string + input-value: output - run: | - if [[ "${{steps.output-set.outputs.result}}" != "test" ]]; then + if [[ "${{steps.output-set.outputs.result}}" != "output" ]]; then exit 1 fi From e4cc5a8d47990cd09075f7d5f619d763f0238dec Mon Sep 17 00:00:00 2001 From: Jonathan Clem Date: Tue, 24 Mar 2020 14:06:45 -0400 Subject: [PATCH 3/3] Add core to README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index cd5c617e7..5b94ec5a6 100644 --- a/README.md +++ b/README.md @@ -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` A reference to the [@actions/core](https://github.com/actions/toolkit/tree/master/packages/core) package Since the `script` is just a function body, these values will already be defined, so you don't have to (see examples below).