It is possible and there are several ways to achieve it. I would propose to use the same host where gitlab is located as runner with shell executor. Basically, you are opening a way in order to run a few commands into this gitlab runner. Now, there are a lot of resources in internet and even in the official docs of gitlab, but to sum up, you will need to follow the next flow:
1. .gitlab-ci.yml
This file should be in the root of your project. It is read and interpreted by gitlab when running CI CD tasks. It can be as complex as you wish, but in my opinion, I like to keep things simple, so I will just invoke an script when master branch is changed.
The content might be something like this:
Check Changelog:
script:
- sh .gitlab/CI-CD-Script.sh ## Execute in the gitlab runner the script.
only:
- master ## It will run only when master branch changes.
2. .gitlab/CI-CD-Script.sh
As mentioned, I prefer to call a script which it will manage the logic of all CI CD. But as previously said, there are multiple ways to achieve same results. Below, you can build an script in the next way:
#!/bin/bash
# Download the original changelog from master branch.
wget http://<yourgitlabAddress>/<pathToProject>/-/raw/master/CHANGELOG.md /tmp/CHANGELOG.md
if cmp -s /tmp/CHANGELOG.md CHANGELOG.md; then ## Checking if files are different.
echo "Changelog not changed"
exit 1 ## Job will fail
else
echo "Changelog changed"
exit 0 ## Job will pass
fi
That would be all so far. I can't try it in your environment, I hope it helps you.