Conditionnal jobs based on sha1sum?

Hello,

I have an app containing both front-end (React) and back-end (PHP Symfony API) source code each with their own Dockerfile.

My workflow is pretty standard :

  • each PR triggers a job that builds both images and runs tests, linters and whatnot
  • each merge on master triggers the deploy on GCP

The problem : doing a simple fix on the back-end/front-end triggers the CI for the other and thus increasing the time it takes (especially yarn dependencies :zzz: )

What I would like to do is the following :

  • with each PR / merge, if the front-end or back-end directory is exactly the same as the precedent pipeline, we skip the whole workflow.

So I have read the doc about conditional steps and caching dependencies but haven’t been able to ties them up together to do what I want.

An hypothetical config file would look like this :
(I have just wrote that in notepad++ so no clue if it is actually valid :slight_smile: )

version: 2.1

defaults: &defaults
    working_directory: ~/directory
    docker:
        - image: cimg/base:stable

filter_merge: &filter_merge
    filters:
        branches:
            ignore:
                - master

only_master: &only_master
    filters:
        branches:
            only:
                - master

commands:
    test_react:
        steps:
            - run:
                  name: Test react app
                  command: |
                      #build image and testing react app
                      #cache sha1sum of react app directory

    test_api:
        steps:
            - run:
                  name: Test react app
                  command: |
                      #build image and test symfony api
                      #cache sha1sum of symfony api directory

    deploy_back:
        steps:
            - run:
                  name: Production deploy back
                  command: |
                      #deploy backend to GCP
                      #cache sha1sum of symfony api directory
    deploy_front:
        steps:
            - run:
                  name: Production deploy front
                  command: |
                      #deploy frontend to GCP
                      #cache sha1sum of react app directory
jobs:
    check_pr:
        <<: *defaults
        steps:
            - setup_remote_docker:
                  version: 20.10.7
            - checkout
            - when:
                  condition: #check if sha1sum of front-end directoty is the same as the cached one
                  steps:
                    - test_react
            - when:
                  condition: #check if sha1sum of back-end directoty is the same as the cached one
                  steps:
                    - test_api

    deploy_prod:
        working_directory: ~/directory
        docker:
            - image: google/cloud-sdk:alpine
        steps:
            - setup_remote_docker:
                  version: 20.10.7
            - checkout
            - when:
                  condition: #check if sha1sum of front-end directoty is the same as the cached one
                  steps:
                    - deploy_front
            - when:
                  condition: #check if sha1sum of back-end directoty is the same as the cached one
                  steps:
                    - deploy_back

workflows:
    version: 2
    check:
        jobs:
            - check_pr:
                  <<: *filter_merge

    deploy:
        jobs:
            - deploy_prod:
                  <<: *only_master

So my question is : is it doable ?

Hope this was clear

Thanks for reading and any help you can provide