Showing results for 
Search instead for 
Did you mean: 
Pilot Lvl 1
Message 1 of 14

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

Solved! Go to Solution.

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:


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!

13 Replies
Pilot Lvl 1
Message 2 of 14

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

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).
Pilot Lvl 1
Message 3 of 14

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

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'
Ground Controller Lvl 1
Message 4 of 14

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

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

Copilot Lvl 2
Message 5 of 14

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

A workaround :(


    runs-on: ubuntu-latest

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

    runs-on: ubuntu-latest
    needs: checkEvent
Pilot Lvl 1
Message 6 of 14

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

Nice workaround :) I'll try that. It's probably better than `if` on every step. Thank you.
Pilot Lvl 1
Message 7 of 14

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

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 ...

Copilot Lvl 3
Message 8 of 14

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

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.

Pilot Lvl 1
Message 9 of 14

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

@rodrigonehrings workaround must the best we can do then...

Thank you for sharing!

Copilot Lvl 3
Message 10 of 14

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

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