I have a nodeJS application which I deploy with Gitlab CI. When pushing to branch XYZ, the corresponding script runs, let's assume on stage 'dev'. That's working. So far so good. Is it possible to select a specific branch so that instead of branch XYZ, e.g. Branch FOO can be deployed on 'dev' without having to change the gitlab-ci.yml file every time?
Instead of hard-coding your branch name in
$CI_COMMIT_REF_NAME. There are a bunch of pre-set environment variables you can use to get info about the current job.
The gitlab documentation has a list of them: https://docs.gitlab.com/ee/ci/variables/predefined_variables.html
each step actually can run on each branch except you limit it with 'only' options. it will be more flexible to you. Please see this documentation section. https://docs.gitlab.com/ee/ci/yaml/#onlyexcept-basic