CI always builds on default branch

I have two branches:

  • master (used only for building releases)
  • development (used for day-to-day development)

In my case development is set as default branch.

I've created .gitlab-ci.yml file that should build release only when tag is added to master branch.

build-package-release:
    stage: build
    script:
        - powershell ...
    only:
        - /^v?\d+\.\d+\.\d+$/ # Run only for tags that have specific version format
    except:
        - /^(?!.*(master|v?\d+\.\d+\.\d+)$).*$/ # Exclude all branches and tags except master and version tags
    artifacts:
        paths: 
            - build-artifacts/*.zip
            
upload-to-shop-release:
    stage: deploy
    script:
        - powershell ...
    only:
        - /^v?\d+\.\d+\.\d+$/ # Run only for tags that have specific version format
    except:
        - /^(?!.*(master|v?\d+\.\d+\.\d+)$).*$/ # Exclude all branches and tags except master and version tags

And it all works great except that gitlab-runner is pulling development branch when running build, probably because it is default branch. When I create new tag in GitLab UI, I choose to create it on master branch.

Is there a way to force CI to pull master branch?

Edited by 🤖 GitLab Bot 🤖