After having to manually update my repo because I forgot to change the version number... twice, I decided it was time for some CI magic.
Here's the deal: if I make a Merge Request into main
, I expect the application version number to have changed in 3 different files.
Here is my code so far:
stages:
- test
- deploy
workflow:
# some rules
unit_test:
stage: test
script:
# run UT
# This is the part the question is about
check_version:
stage: test
rules:
- if: '$CI_PIPELINE_SOURCE' == "merge_request_event" && '$CI_MERGE_REQUEST_TARGET_BRANCH_NAME' == '$CI_DEFAULT_BRANCH'
changes:
- composer.json
- resources/index.php
- Doxyfile
deploy:
stage: deploy
script:
# deployment script
rules:
- if: '$CI_COMMIT_BRANCH' == '$CI_DEFAULT_BRANCH'
If I understood things correctly, what I did is "If it's a Merge Request into main
, check for changes in composer.json
, resources/index.php
and Doxyfile
".
First: is it correct?
Second: what do I do to allow pushes and Merge Requests in other branches? Is there some kind of "else" that follows the "if"?