1

I have created a deployment.yaml, which builds my code every time I make a push to the master branch.

This is my project structure.

project1
|-subproject1
|-subproject2
|-subproject3

Now, I have 3 different jobs that builds each of this subprojects.

can I add a condition in such a way.. that if I make changes only in subproject2, then only that particular job should run.

I found that the jobs have an if property.

https://docs.github.com/en/actions/using-jobs/using-conditions-to-control-job-execution

So, in short I want to write something like ...

jobs:
  deploy:
    if: old_subproject1 != new_subproject1

...
jobs:
  deploy:
    if: old_subproject2 != new_subproject2
...
jobs:
  deploy:
    if: old_subproject3 != new_subproject3

Thanks in advance !

Keval Bhogayata
  • 4,422
  • 3
  • 13
  • 36
  • 1
    See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#onpushpull_requestpull_request_targetpathspaths-ignore – Nick ODell Jan 29 '22 at 06:03

1 Answers1

8

You can do that with path filter:

on:
  push:
    branches:
      - 'master'
    paths:
      - 'project1/subproject1/**/*'

And do it for each 3 jobs.

See: https://docs.github.com/en/actions/using-workflows/triggering-a-workflow#using-filters-to-target-specific-paths-for-pull-request-or-push-events

Ady
  • 190
  • 1
  • 6