action-workflow_run-status icon indicating copy to clipboard operation
action-workflow_run-status copied to clipboard

Job not found

Open polarathene opened this issue 3 years ago • 3 comments

Workflow snippet triggered on workflow_run:

jobs:
  preview:
    name: 'Deploy Preview'
    runs-on: ubuntu-20.04
    if: ${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' }}
    steps:
      - uses: haya14busa/action-workflow_run-status@v1

This workflow works correctly, but breaks when trying to use this action as above. Actions error log:

Run haya14busa/action-workflow_run-status@v1
  with:
    github_token: ***
    requested_as_pending: true
Error: job not found: preview

This is likely the same issue that was recently closed by the issue author for unknown reasons. Unlike others chiming in there I am not using any matrix.


Quick glance over the code suggests that job.name is probably Deploy Preview which is obviously not going to match the context.job that the error logs as preview. Presumably if I match the name value to the job object name the two values will resolve this issue.

https://github.com/haya14busa/action-workflow_run-status/blob/967ed83efa565c257675ed70cfe5231f062ddd94/src/main.ts#L84-L87

It looks like you could reference a job by id? For those using a matrix, that may not work? context.github.job provides the current job id. Will this work?:

const job = jobs.data.jobs.find(j => j.id === context.github.job)

I don't develop actions, and the documentation is lacking what the context.job.job object contains. One issue I linked to mentions context.jobId but I am lacking documentation to know if that's suggested or valid.

polarathene avatar May 12 '21 05:05 polarathene

Confirmed. Setting name: 'preview' satisfies the action match for j.name === context.job. This is undesirable.

polarathene avatar May 12 '21 05:05 polarathene

Yes. I can confirm that defining a name in the job causes this action to fail.

phosphene avatar Oct 11 '21 16:10 phosphene

Defining a name or using matrix will cause this problem. Would be great if it could be solved.

cattermo avatar Oct 18 '21 10:10 cattermo