This can be achieved through a gitlab-ci pipeline task. Essentially you will need to merge to master and push. Unfortunately there is no direct way for a gitlab runner to push to remote.
The below is a workaround
- Setup ssh key in a
before_script
- Make the git updates locally
- Push to remote
Sample code below
merge_to_master:
before_script:
- which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )
- eval `ssh-agent -s`
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- ssh-keyscan -H <Your gitlab server> >> ~/.ssh/known_hosts
- ssh -vT git@<Your gitlab server>
variables:
VERSION: "$CI_PIPELINE_ID"
VERSIONNAME: "$CI_COMMIT_REF_SLUG"
only:
- <Review* or similar>
script:
- export LC_CTYPE=en_US.UTF-8
- git config --global user.email "Some user email - Typically the machine user"
- git config --global user.name "Some name"
- git checkout master
- git merge $CI_COMMIT_REF_NAME
- git push ssh://git@<Your gitlab server>/<Repo> HEAD:master
stage: dev_deploy
$SSH_PRIVATE_KEY
- Environment variable containing the private SSH key for git Refer https://help.github.com/en/github/authenticating-to-github/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent
[ci skip]
- Add only if you want to skip the build after the push
rebase
master with review or you want tomerge
the review to the master ? – Declare