Merge pull request #33 from actions/add-core

Add core to execution context
This commit is contained in:
Jonathan Clem
2020-03-24 14:08:04 -04:00
committed by GitHub
4 changed files with 6 additions and 4 deletions

View File

@@ -8,9 +8,10 @@ jobs:
- id: output-set - id: output-set
uses: actions/github-script@master uses: actions/github-script@master
with: with:
script: return 'test' script: return core.getInput('input-value')
result-encoding: string result-encoding: string
input-value: output
- run: | - run: |
if [[ "${{steps.output-set.outputs.result}}" != "test" ]]; then if [[ "${{steps.output-set.outputs.result}}" != "output" ]]; then
exit 1 exit 1
fi fi

View File

@@ -11,6 +11,7 @@ be provided:
[octokit/rest.js](https://github.com/octokit/rest.js) client [octokit/rest.js](https://github.com/octokit/rest.js) client
- `context` An object containing the [context of the workflow - `context` An object containing the [context of the workflow
run](https://github.com/actions/toolkit/tree/master/packages/github) 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 Since the `script` is just a function body, these values will already be
defined, so you don't have to (see examples below). defined, so you don't have to (see examples below).

2
dist/index.js vendored
View File

@@ -9178,7 +9178,7 @@ async function main() {
const github = new lib_github.GitHub(token, opts); const github = new lib_github.GitHub(token, opts);
const script = Object(core.getInput)('script', { required: true }); const script = Object(core.getInput)('script', { required: true });
// Using property/value shorthand on `require` (e.g. `{require}`) causes compilatin errors. // 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'); let encoding = Object(core.getInput)('result-encoding');
encoding = encoding ? encoding : 'json'; encoding = encoding ? encoding : 'json';
let output; let output;

View File

@@ -19,7 +19,7 @@ async function main() {
// Using property/value shorthand on `require` (e.g. `{require}`) causes compilatin errors. // Using property/value shorthand on `require` (e.g. `{require}`) causes compilatin errors.
const result = await callAsyncFunction( const result = await callAsyncFunction(
{require: require, github, context}, {require: require, github, context, core},
script script
) )