Feature Request: job.<job id>.on

I would like to have a workflow with 2 jobs.  The first job should run on every branch push.  The second job depends on the first job and should only be run on a master branch push.  This would require the on (https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#on) functionality to work at the job level.  

This could also be solved if I could make a workflow depend on other workflows.  That is, if the need (https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#jobsjob_idneeds) functionality worked at the workflow level.

Hi @alankuurstra!

This is actually currently possible using jobs.<job id>.if conditional with the github.ref context item.

Here is an example:

jobs:
  job1:
    steps:
      - run: echo "I always execute!"
  job2:
    if: github.ref == 'refs/heads/master'
    steps:
      - run: echo "I only execute on master branch!"
job3:
if: contains(github.ref, 'release')
steps:
- run: echo "I only run if the pushed branch contains 'release' in its name!
2 Likes

Thanks for the work around!

1 Like