`jobs.<job_id>.if` not working?

I have created a workflow with jobs.<job_id>.if but it fails with:

- Your workflow file was invalid: .github/workflows/test.yml (Line: 7, Col: 5): Unexpected value 'if'

Documentation says it should be possible.

I created a small example at: https://github.com/reload/actions-test/pull/1/checks

Edit August 14, 2019:  jobs.<job_id>.if has been removed from the documentation now. See workaround below.

Edit October 1, 2019: it’s back, working and documented!


As a workaround I moved the if condition into each step in the job.

There are some drawbacks to that though.

  • I need to remember the condition on each step in the job
  • When step uses actions docker containers for each step is still being build and only the execution of the step is being ignored.
    This results in time wasted on builds I don’t need. And wasted time is slower feedback loops, wasted money (on a paid plan) and wasted computing resources (global warming, etc).

I’m having the same issue, putting the if in each step is a pain in the ass.

    name: Publish release
    # this causes errors
    if: github.event.action == 'published'
1 Like

I need also this feature, it works on steps but not at the job level.


A workaround :frowning:

    runs-on: ubuntu-latest

      - name: if published
        if: github.event.action != 'published'
        run: exit 1

    runs-on: ubuntu-latest
    needs: checkEvent

Nice workaround :slight_smile: I’ll try that. It’s probably better than if on every step. Thank you.

I have the same problem and have asked github support group for help. And I got their reply just now. It seems jobs doesn’t support if statement right now. And the online document is updated and jobs.<job_id>.if  seems to be removed.


@rodrigonehrings workaround must the best we can do then…

Thank you for sharing!

1 Like

Ok, I tried the aproach now and it doesn’t give the result I was hoping for.

Since this workaround will make the check job fail if the condition is met we end up with a failed job on i.e. a Pull Request. I wss aiming at something like neutral / skipped.

So back to if on each step then …

I just tried this and it works as expected. I guess the feature is back but documentation is still missing.


Yes! I tried it as well and it worked!

Now let’s hope it stays / gets documented.

One caveat / percularity:

If you add jobs.<job_id>.if to all jobs of the workflow and none of them evalute to true none of the actions will be run (as expected) and the workflow/jobs will not show up on a pull request (also a expected). But if you go to the Actions tab you will see teh workflow running and appearing to run forever (doing nothing).


And with todays announcement (https://github.blog/changelog/2019-10-01-github-actions-new-workflow-syntax-features/) it is also documented again!


For some reasons the jobs dont even show up… Can you share your snippet?