I'm trying to implement a gitlab ci pipeline that will only be triggered if files in a specific directory or its subdirectories are changed.
stages:
# - pre
- triggers
.schema_trigger: &trigger_config
trigger:
include: pipeline/zone.gitlab-ci.yml
strategy: depend
#pre-stage:
# image: centos:7
# stage: pre
# script:
# - echo "This job ensures that when no migrations are added the pipeline is still successfull"
demo:
stage: triggers
variables:
SCHEMA: demo
<<: *trigger_config
only:
refs:
- merge_requests
changes:
- schemas/demo/**/*.{sql,env}
Problem is that when i create a new merge request without changes in the schemas/demo dir the pipeline still runs. I've tried some configurations without success, including adding the only:refs clause with the only effect of creating a detached pipeline.
And this issue only presents itself on the first pipeline for the branch, all commits after are evaluated correctly and don't run.
How would i be able to achieve the goal of having the pipeline only run when files in the directory are changed?