hramos / respond-to-issue-based-on-label

A GitHub Action to Respond to Issues Based on Label
MIT License
11 stars 2 forks source link

Compatibility with pull requests #12

Open jywarren opened 2 years ago

jywarren commented 2 years ago

Hello, we love your action here, but ran into an error. I triggered it by adding the label to a PR, and got it to error, restarted the job with debugging enabled, and found the below error:

https://github.com/publiclab/mapknitter/runs/6625990189?check_suite_focus=true

##[debug]Evaluating condition for step: 'Process Label Action'
##[debug]Evaluating: success()
##[debug]Evaluating success:
##[debug]=> true
##[debug]Result: true
##[debug]Starting: Process Label Action
##[debug]Loading inputs
##[debug]Evaluating: secrets.GITHUB_TOKEN
##[debug]Evaluating Index:
##[debug]..Evaluating secrets:
##[debug]..=> Object
##[debug]..Evaluating String:
##[debug]..=> 'GITHUB_TOKEN'
##[debug]=> '***'
##[debug]Result: '***'
##[debug]Loading env
Run hramos/label-actions@v[2](https://github.com/publiclab/mapknitter/runs/6625990189?check_suite_focus=true#step:3:2)
  with:
    configuration-path: .github/label-actions.yml
    repo-token: ***
    perform: true
##[debug]Label added: dependencies
Error: TypeError: Cannot read property 'number' of undefined
Error: Cannot read property 'number' of undefined
##[debug]Node Action run completed with exit code 1
##[debug]Finishing: Process Label Action

I think it refers to this line, reading issue.number, and it occurred to me that maybe this isn't designed to work with pull requests? Is that true?

https://github.com/hramos/respond-to-issue-based-on-label/blob/a366dfe725db739c4522391dd1cb3daa9cb399d5/src/respond-to-issue-based-on-label.js#L34

https://docs.github.com/en/developers/webhooks-and-events/events/issue-event-types#event-object-properties-18 this has changed but i think this is for the event object and the 2nd returned item in the payload should be distinct...

I also looked and found that the .number property seems to be available for pull request events, not issue events, so that left me more confused: https://docs.github.com/en/developers/webhooks-and-events/events/github-event-types#pullrequestevent

Is our problem that this isn't designed for use on pull requests? Thank you!

jywarren commented 2 years ago

Just noting that @PeculiarE ended up writing a custom workflow to solve this, and it does work with PRs! https://github.com/publiclab/mapknitter/pull/1734#issuecomment-1140147943