: "${GITLAB_BOT_CI_TOKEN:?Environment variable GITLAB_CI_TOKEN needs to be set as secret CI variable in GitLab before running this script}"

# This perl command extracts the ssh/git URL because the runner uses a tokenized URL
export CI_PUSH_REPO=`echo $CI_REPOSITORY_URL | perl -pe 's#.*@(.+?(\:\d+)?)/#git@\1:#'`
git config --global user.name "gitlab-bot"
git config --global user.email "git@brickblock.io"
git remote set-url --push origin "${CI_PUSH_REPO}"
git push https://gitlab-bot:${GITLAB_BOT_CI_TOKEN}@git.brickblock-dev.io/${CI_PROJECT_PATH} master --follow-tags
