auth-app.js: [BUG]: unable to use this package with `@actions/github-script`
What happened?
It looks like between 5.0.4 and 5.0.5 dependencies were updated. I suspect that the upgrade from @octokit/request 6.0.0 to 7.0.0 may have caused this issue.
The following code throws an error in 5.0.5 when run under actions/github-script@v6
const { createAppAuth } = require("@octokit/auth-app");
const key = `${{ secrets.PrivKey }}`
var auth = createAppAuth({appId: "${{vars.APPID}}", privateKey: key });
var authentication = await auth({type: "installation", installationId: "${{vars.INSTALLID}}" })
return authentication.token
Error:
Error: Global "fetch" not found. Please provide `options.request.fetch` to octokit or upgrade to node@18 or newer.
at fetchWrapper (/home/runner/work/tf-project/tf-project/node_modules/@octokit/request/dist-node/index.js:56:11)
at newApi (/home/runner/work/tf-project/tf-project/node_modules/@octokit/request/dist-node/index.js:176:14)
at getInstallationAuthentication (/home/runner/work/tf-project/tf-project/node_modules/@octokit/auth-app/dist-node/index.js:238:13)
at async eval (eval at callAsyncFunction (/home/runner/work/_actions/actions/github-script/v6/dist/index.js:15143:16), <anonymous>:34:[22](https://github.com/sah-test/tf-project/actions/runs/5316189964/jobs/9625440887#step:4:23))
at async main (/home/runner/work/_actions/actions/github-script/v6/dist/index.js:15[23](https://github.com/sah-test/tf-project/actions/runs/5316189964/jobs/9625440887#step:4:24)6:20)
Error: Unhandled error: Error: Global "fetch" not found. Please provide `options.request.fetch` to octokit or upgrade to node@18 or newer.
Makes me also wonder if the semver should be bumped by a major version if dependencies are bumped by a major version…
Thanks, Shane
Versions
@octokit/auth-app@5.0.5 actions/github-script@v6
Relevant log output
Run actions/github-script@v6
with:
script: const { createAppAuth } = require("@octokit/auth-app");
const key = `***
`
var auth = createAppAuth({appId: "***", privateKey: key });
var authentication = await auth({type: "installation", installationId: "***" })
return authentication.token
github-token: ***
debug: false
user-agent: actions/github-script
result-encoding: json
retries: 0
retry-exempt-status-codes: 400,401,403,404,422
env:
WORKING_DIR: .
ENVIRONMENT: development
Error: Global "fetch" not found. Please provide `options.request.fetch` to octokit or upgrade to node@18 or newer.
at fetchWrapper (/home/runner/work/tf-project/tf-project/node_modules/@octokit/request/dist-node/index.js:56:11)
at newApi (/home/runner/work/tf-project/tf-project/node_modules/@octokit/request/dist-node/index.js:176:14)
at getInstallationAuthentication (/home/runner/work/tf-project/tf-project/node_modules/@octokit/auth-app/dist-node/index.js:238:13)
at async eval (eval at callAsyncFunction (/home/runner/work/_actions/actions/github-script/v6/dist/index.js:15143:16), <anonymous>:34:22)
at async main (/home/runner/work/_actions/actions/github-script/v6/dist/index.js:15236:20)
Error: Unhandled error: Error: Global "fetch" not found. Please provide `options.request.fetch` to octokit or upgrade to node@18 or newer.
Code of Conduct
- I agree to follow this project’s Code of Conduct
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 2
- Comments: 19 (8 by maintainers)
Commits related to this issue
- fix(deps): upgrade `@octokit/endpoint` For some reason, clients are not getting the updated version of `@octokit/endpoint` via other packages that require `@octokit/request` See https://github.com/o... — committed to octokit/request.js by wolfy1339 a year ago
- fix(deps): upgrade `@octokit/endpoint` (#597) For some reason, clients are not getting the updated version of `@octokit/endpoint` via other packages that require `@octokit/request` See https://git... — committed to octokit/request.js by wolfy1339 a year ago
- fix(CI): github scripts get token error fix by config nodejs version to 18 Issue: https://github.com/octokit/auth-app.js/issues/499 — committed to hudeng-go/.github by hudeng-go a year ago
- fix(CI): github scripts get token error fix by config nodejs version to 18 Issue: https://github.com/octokit/auth-app.js/issues/499 — committed to deepin-community/.github by hudeng-go a year ago
@KevinMSampson Thanks Kevin 😃
I misread that and didn’t pin the Node version to 16. This solved the issue.
@KevinMSampson Thanks Kevin 😃
I misread that and didn’t pin the Node version to 16. This solved the issue.
Can confirm, I am also using github-script.
I think it may be that both @shaneholder and I are using the octokit/auth-app wrapped within the actions/github-script which provides it’s own reference to fetch and only supports up to node 16 it seems