actions / github-script

Write workflows scripting the GitHub API in JavaScript
MIT License
4.13k stars 410 forks source link

Unhandled error: TypeError: Cannot read properties of undefined (reading 'listWorkflowRunArtifacts') #242

Closed kfiven closed 2 years ago

kfiven commented 2 years ago

Hi, I am using this action to deploy pull requests, see https://github.com/kfiven/cinny/blob/test/.github/workflows/deploy-pull-request.yml

After upgrading to v6 (from v3.1.0) I am getting following error:

TypeError: Cannot read properties of undefined (reading 'listWorkflowRunArtifacts')
[36](https://github.com/kfiven/cinny/runs/5303357611?check_suite_focus=true#step:2:36)
Error: Unhandled error: TypeError: Cannot read properties of undefined (reading 'listWorkflowRunArtifacts')
[37](https://github.com/kfiven/cinny/runs/5303357611?check_suite_focus=true#step:2:37)
    at eval (eval at callAsyncFunction (/home/runner/work/_actions/actions/github-script/v6/dist/index.js:4797:16), <anonymous>:3:[38](https://github.com/kfiven/cinny/runs/5303357611?check_suite_focus=true#step:2:38))
38
    at callAsyncFunction (/home/runner/work/_actions/actions/github-script/v6/dist/index.js:4798:12)
[39](https://github.com/kfiven/cinny/runs/5303357611?check_suite_focus=true#step:2:39)
    at main (/home/runner/work/_actions/actions/github-script/v6/dist/index.js:4852:26)
[40](https://github.com/kfiven/cinny/runs/5303357611?check_suite_focus=true#step:2:40)
    at Module.272 (/home/runner/work/_actions/actions/github-script/v6/dist/index.js:4836:1)
[41](https://github.com/kfiven/cinny/runs/5303357611?check_suite_focus=true#step:2:41)
    at __webpack_require__ (/home/runner/work/_actions/actions/github-script/v6/dist/index.js:24:31)
[42](https://github.com/kfiven/cinny/runs/5303357611?check_suite_focus=true#step:2:42)
    at startup (/home/runner/work/_actions/actions/github-script/v6/dist/index.js:[43](https://github.com/kfiven/cinny/runs/5303357611?check_suite_focus=true#step:2:43):19)
43
    at /home/runner/work/_actions/actions/github-script/v6/dist/index.js:49:18
[44](https://github.com/kfiven/cinny/runs/5303357611?check_suite_focus=true#step:2:44)
    at Object.<anonymous> (/home/runner/work/_actions/actions/github-script/v6/dist/index.js:52:10)
[45](https://github.com/kfiven/cinny/runs/5303357611?check_suite_focus=true#step:2:45)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
[46](https://github.com/kfiven/cinny/runs/5303357611?check_suite_focus=true#step:2:46)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)

See https://github.com/kfiven/cinny/runs/5303357611?check_suite_focus=true#step:2:1

joshmgross commented 2 years ago
var artifacts = await github.actions.listWorkflowRunArtifacts({
                     owner: context.repo.owner,
                     repo: context.repo.repo,
                     run_id: ${{github.event.workflow_run.id }},
                  });

In V5 of this action, we upgraded Octokit and REST methods now need to be referenced by github.rest - https://github.com/actions/github-script#breaking-changes-in-v5

This should be github.rest.actions.listWorkflowRunArtifacts rather than github.actions.listWorkflowRunArtifacts

kfiven commented 2 years ago

Thanks Josh! I somehow missed readme and was looking for breaking changes in releases.

joshmgross commented 2 years ago

I somehow missed readme and was looking for breaking changes in releases.

Oops, sorry about that. I should have included that in the release notes, I've updated https://github.com/actions/github-script/releases/tag/v5.0.0 to include this breaking change.