Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Copilot Lvl 3
Message 1 of 3

Feature Request: job.<job id>.on

Solved! Go to Solution.

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-... 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-synta... functionality worked at the workflow level.

2 Replies
Solution
Copilot Lvl 2
Message 2 of 3

Re: Feature Request: job.<job id>.on

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!
Copilot Lvl 3
Message 3 of 3

Re: Feature Request: job.<job id>.on

Thanks for the work around!