last-successful-commit-action icon indicating copy to clipboard operation
last-successful-commit-action copied to clipboard

Action assumes "push" events triggered the last workflow run, which is not always true

Open simondotm opened this issue 4 years ago • 4 comments

This is a very useful action, however I have a use-case where I'm checking for a workflow run that was triggered by either a workflow_dispatch or workflow_run and the script always returns an empty commit hash, because it's hard coded to check for push events.

Ideally the workflow event type sent to the API can be optionally specified as an action input eg.:

  octokit.actions
    .listWorkflowRuns({
      owner,
      repo,
      workflow_id: core.getInput("workflow_id"),
      status: "success",
      branch: core.getInput("branch"),
      event: core.getInput("event") || "push",
    })

simondotm avatar Jun 22 '21 09:06 simondotm

To test a solution, I've forked this action and modified a v2 of this action to only specify event filter in the API call if an explicit workflow_event input is set. In this way, the action will return all successful workflow runs regardless of the event that triggered them If users want to be specific about which event triggered the last workflow run, they can add the optional workflow_event input parameter to their action.

simondotm avatar Jun 22 '21 10:06 simondotm

It would be great to have this added in! Having the same issue.

psteinroe avatar Jul 12 '21 07:07 psteinroe

Test this action with my manual trigger workflow which relies on workflow event (on: workflow_dispatch). The action was not able to return any value while it used to work well with push event. There is a huge value can be add to this action if it is able to support workflow event. Cheers,

kateluu-comdev avatar Nov 11 '21 23:11 kateluu-comdev

I'm having the same issue.

Thanks @simondotm for fixing that. I will try out our version.

However, would be cool to have that in the main repo.

pascalbe-dev avatar Jul 06 '22 12:07 pascalbe-dev