Skip to content

Instantly share code, notes, and snippets.

@fuacici
Created July 18, 2017 02:36
Show Gist options
  • Select an option

  • Save fuacici/d9a38ee756a5d772d26483afbf80ba84 to your computer and use it in GitHub Desktop.

Select an option

Save fuacici/d9a38ee756a5d772d26483afbf80ba84 to your computer and use it in GitHub Desktop.
.gitlab-ci.yml & Shell scripts for auto merge request
stages:
- load_branches
- master_merge
variables:
create_merge:
stage: master_merge
only:
- master
- ci
tags:
- merge_master
when:
always
script:
- echo $(sh ./create_merges.sh)
BRANCH_TO_MERGE=$(git for-each-ref --format='%(refname:short)' refs/remotes/ |grep -o "DEV_.\+BR$")
for BRANCH in $BRANCH_TO_MERGE
do
echo $BRANCH
echo $(curl -d source_branch=$CI_BUILD_REF_NAME -d target_branch=$BRANCH -d title=Auto_Merge-Master-to-$BRANCH -d description=default "http://git.xxx.com/api/v3/projects/$CI_PROJECT_ID/merge_requests/?private_token=$GITLAB_API_TOKEN")
done
# Please get project id from triggers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment