Is it possible to run the job only when a specific file changes?

Is there a syntax to define a job to run only if some files change comparing to last commit?

1 Like

There is, you can use on.<push|pull_request>.paths syntax for that. E.g. to run only on pushes that changed example.c:

      - 'example.c'

You can use globs.

Thanks for your reply!

on.<push|pull_request>.paths can only make a workflow to run when some designated files change, but not a job. I wonder if there is a way to to only run specific jobs when some files change within a workflow.

You could set job level outputs in a previous job A. Use git command to check whether file changed during the workflow run. And then if file changed , you could set an output variable to true using ```
::set-output command.
Also please add needs : [ jobA ] in next jobs , add job if conditional, if the output variable is true then run these jobs.
There is the syntax for jobs.<jobs_id>.outputs .