We think you might be interested in this job:
I wanted to save some time on our runners in GitLab and decided to only run phpcs on changed files for that merge request. I also wanted it to run as a git commit hook to try and prevent bad code from even getting pushed up. What I came up with was to add two shell scripts to the repo under the folder bin. changed.sh (chmod u+x) Add the following to your .gitlab-ci.yml changed.sh could just go inside the yml file, but I like using it before deploys.