Is there a way to skip deploy if only tests changed?

,

Either rules:changes or rules:changes:compare_to. You can also use variables in rules:changes to create more dynamic rules.

deploy-to-prod:
  script:
    - echo "Deploying to prod"
  rules:
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
      changes:
        - backend/**/*
        - frontend/**/*

If rules are not sufficient, you can go one step further, and build the deployment gate into the job script itself, e.g. by getting a diff of the changed files, and determine if there are changes that warrant the deployment trigger. Or call exit 1 to signal skipping the deployment, but this needs allow_failure: true on the job. Alternatively, just log the skip and run exit 0. CI/CD pipeline - get list of changed files - #16 by anarcat has a few examples in the discussion.