circlecicircleci-2.0cicdcircleci-workflowsgithub-ci

How to run a CircleCI job in a github repo only if a file in the same repo is added a new entry?


I have added a job in the existing circleci workflow, I would like to run that job only if a yaml file is changed in the repo. Is there any way to do it ? TIA.


Solution

  • you can detect changes in circlci build step and run job only if yml files changed

    - run: |
        git show --name-only ${CIRCLE_SHA1} | grep .yml
    
        if [ $? -eq 0 ]; then 
          echo "yml files changed" 
          // Do your job steps
        fi