]> granicus.if.org Git - esp-idf/commitdiff
build/CI: Push all allocated release branches to github
authorAngus Gratton <angus@espressif.com>
Tue, 14 Mar 2017 09:27:56 +0000 (17:27 +0800)
committerAngus Gratton <angus@espressif.com>
Wed, 15 Mar 2017 09:36:41 +0000 (17:36 +0800)
Previously CI deployment only pushed to master.

.gitlab-ci.yml

index 1a88a2e80edff780e3e65ecabffad8679a0385a4..9818930c99b37c79b107e34368a5b0b9b64d8f6c 100644 (file)
@@ -225,6 +225,7 @@ push_master_to_github:
   image: espressif/esp32-ci-env
   variables:
     GIT_STRATEGY: clone
+    GITHUB_PUSH_REFS: refs/remotes/origin/release refs/remotes/origin/master
   script:
     - mkdir -p ~/.ssh
     - chmod 700 ~/.ssh
@@ -233,7 +234,14 @@ push_master_to_github:
     - chmod 600 ~/.ssh/id_rsa
     - echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
     - git remote add github git@github.com:espressif/esp-idf.git
-    - git push --follow-tags github HEAD
+    # What the next line of script does: goes through the list of refs for all branches we push to github,
+    # generates a snippet of shell which is evaluated. The snippet checks CI_BUILD_REF against the SHA
+    # (aka objectname) at tip of each branch, and if any SHAs match then it checks out the local branch
+    # and then pushes that ref to a corresponding github branch
+    #
+    # NB: In gitlab 9.x, CI_BUILD_REF was deprecated. New name is CI_COMMIT_REF. If below command suddenly
+    # generates bash syntax errors, this is probably why.
+    - eval $(git for-each-ref --shell bash --format 'if [ $CI_BUILD_REF == %(objectname) ]; then git checkout -b %(refname:strip=3); git push --follow-tags github %(refname:strip=3); fi;' $GITHUB_PUSH_REFS)
 
 
 deploy_docs: