Adding a condition to run specific job inside main workflow file

Hi,

Inside my repo I need to build 3 JARs. I currently have a workflow which builds all of them even though commit/update comes to one component.

Is there a way that I can provide a condition to match the path the commit comes and execute that job only.

Current job:

on:
 push:
  paths:
    -'main/component/path/**'
jobs:
 build_jar_1

 build_jar_2

 build_jar_3

What I need :

on:
 push:
  paths:
    -'main/component/path/**'
jobs:
 build_jar_1
 if  path == 'sub/component/path_1'

 build_jar_2
 if  path == 'sub/component/path_2'

 build_jar_3
  if  path == 'sub/component/path_3'

Hi @gayashankgithub, welcome to the GitHub Support Community! There isn’t a simple way to do this at the job level. You’d have to write your own custom script to compare the paths with the git diff in this case.

I think the simplest solution here would be to have separate workflow files for each case. That way you could rely on the built-in on.<push|pull_request>.paths filter to run specific workflows only when certain paths are modified.