Describe the bug
Following the example here: https://github.com/actions/github-script#run-a-separate-file I'd expect to be able to access the github and context arguments in the separate file.
However it's returning an error:
TypeError: Cannot read property 'payload' of undefined
at module.exports (/home/runner/work/nct-lz-branch-action-dev/nct-lz-branch-action-dev/src/branchNameCheck.js:2:20)
at eval (eval at callAsyncFunction (/home/runner/work/_actions/actions/github-script/v2/dist/index.js:7985:56), <anonymous>:4:13)
at callAsyncFunction (/home/runner/work/_actions/actions/github-script/v2/dist/index.js:7986:12)
at main (/home/runner/work/_actions/actions/github-script/v2/dist/index.js:8011:26)
at Module.833 (/home/runner/work/_actions/actions/github-script/v2/dist/index.js:7995:1)
at __webpack_require__ (/home/runner/work/_actions/actions/github-script/v2/dist/index.js:22:30)
at startup (/home/runner/work/_actions/actions/github-script/v2/dist/index.js:37:19)
at /home/runner/work/_actions/actions/github-script/v2/dist/index.js:43:18
at Object.<anonymous> (/home/runner/work/_actions/actions/github-script/v2/dist/index.js:46:10)
at Module._compile (internal/modules/cjs/loader.js:959:30)
If I change the example separate file to return github that works fine:
Run actions/github-script@v2.
with:
script: const script = require(/`${process.env.GITHUB_WORKSPACE}/src/branchNameCheck.js/`).
console.log(script({github, context})).
github-token: ***.
debug: false.
user-agent: actions/github-script.
result-encoding: json.
{.
github: OctokitWithDefaults {.
request: [Function: newApi] {.
endpoint: [Function],
defaults: [Function: bound withDefaults].
},
graphql: [Function: newApi] {.
...
...
...
Changing the example to return context returns undefined
I also tried with `actions/github-script@v3 but no joy there either.
To Reproduce
Steps to reproduce the behavior:
- Use the Separate file example from (https://github.com/actions/github-script#run-a-separate-file)
- Check the Action output
- See context is undefined
Expected behavior
I'd expect to be able to access the context values in the separate script file, or that the example doesn't fail
Describe the bug
Following the example here: https://github.com/actions/github-script#run-a-separate-file I'd expect to be able to access the
githubandcontextarguments in the separate file.However it's returning an error:
If I change the example separate file to
return githubthat works fine:Changing the example to
return contextreturnsundefinedI also tried with `actions/github-script@v3 but no joy there either.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
I'd expect to be able to access the
contextvalues in the separate script file, or that the example doesn't fail