Cannot read property 'id' of undefined - in on: workflow_dispatch
mkarnicki opened this issue · 4 comments
It seems that workflow_dispatch event is not correctly handled, full stack trace below.
Error:
TypeError: Cannot read property 'id' of undefined
I believe this line is the source of the problem. It is not a pull request, so it tries to reach for payload.head_commit.id
const commitId = isPullRequest ? payload.pull_request.head.sha : payload.head_commit.id;
Stack trace:
Run webfactory/create-aws-codedeploy-deployment@v0.2.2
with:
application: redacted
env:
SERVICE_ROLE_ARN: ***
AWS_DEFAULT_REGION: eu-west-1
AWS_REGION: eu-west-1
AWS_ACCESS_KEY_ID: ***
AWS_SECRET_ACCESS_KEY: ***
(node:1872) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'id' of undefined
at /home/runner/work/_actions/webfactory/create-aws-codedeploy-deployment/v0.2.2/dist/index.js:194:90
at Object.2932 (/home/runner/work/_actions/webfactory/create-aws-codedeploy-deployment/v0.2.2/dist/index.js:203:3)
at __webpack_require__ (/home/runner/work/_actions/webfactory/create-aws-codedeploy-deployment/v0.2.2/dist/index.js:50113:43)
at /home/runner/work/_actions/webfactory/create-aws-codedeploy-deployment/v0.2.2/dist/index.js:50130:18
at Object.<anonymous> (/home/runner/work/_actions/webfactory/create-aws-codedeploy-deployment/v0.2.2/dist/index.js:50131:12)
at Module._compile (internal/modules/cjs/loader.js:959:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
at Module.load (internal/modules/cjs/loader.js:815:32)
at Function.Module._load (internal/modules/cjs/loader.js:727:14)
at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10)
(node:1872) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:1872) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Have a great day and thanks for this awesome custom GH Action. It works well otherwise (with non-workflow_dispatch events).
Is the workflow_dispatch event somehow related to a commit?
What would be your expected result, which commit should be deployed?
GitHub allows you to choose which branch you want to use, and also extra custom input fields (I don't use the extra fields). I've never authored an action, and I'm having hard time finding which event property / github context field would expose the branch name.
The step before that is actions/checkout@v2, so I would expect that checked out source is used - is this how it could work? Since I only provide the branch to the workflow, I would like the HEAD of it to be deployed. Is that reasonable?
In case it's useful, here's the original announcement of when it was introduced on GitHub.
The event that triggers the workflow has GITHUB_SHA (and GITHUB_REF). Is this something you could use perhaps?
Here's the link to the event documentation. Appreciate your input on this, thank you :)