Gitlab CI - Change branch dynamically
Instead of hard-coding your branch name in .gitlab-ci.yml use $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