]> granicus.if.org Git - esp-idf/commitdiff
ci: Fix spurious pipeline failure when deploying a tag to GitHub
authorAngus Gratton <angus@espressif.com>
Thu, 16 Aug 2018 01:04:28 +0000 (11:04 +1000)
committerAngus Gratton <gus@projectgus.com>
Wed, 22 Aug 2018 03:11:18 +0000 (13:11 +1000)
Everything succeeds, but because [ -z ${CI_COMMIT_TAG} ] on the last line returns non-zero, it
fails the job.

.gitlab-ci.yml
tools/ci/executable-list.txt
tools/ci/push_to_github.sh [new file with mode: 0755]

index 7818a02f93523a418f989852d369dee67b6c8b00..6e75082ec1f7ef324ae877e0aaf9a3ec54959fa1 100644 (file)
@@ -388,9 +388,7 @@ push_to_github:
     - echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
     - git remote remove github &>/dev/null || true
     - git remote add github git@github.com:espressif/esp-idf.git
-    # Need separate push commands for tag builds and for branch builds
-    - "[ -n \"${CI_COMMIT_TAG}\" ] && git push github ${CI_COMMIT_TAG}"
-    - "[ -z \"${CI_COMMIT_TAG}\" ] && git push github ${CI_COMMIT_SHA}:refs/heads/${CI_COMMIT_REF_NAME}"
+    - tools/ci/push_to_github.sh
 
 deploy_docs:
   stage: host_test
index 18361a7c90973924c972ae7c638770b3b5f7feba..605cdd1ca351d08e83198def6255f62e32f2d0d2 100644 (file)
@@ -21,6 +21,7 @@ tools/ci/checkout_project_ref.py
 tools/ci/get-full-sources.sh
 tools/ci/mirror-submodule-update.sh
 tools/ci/mirror-synchronize.sh
+tools/ci/push_to_github.sh
 tools/ci/test_build_system.sh
 tools/ci/test_configure_ci_environment.sh
 tools/esp_app_trace/apptrace_proc.py
diff --git a/tools/ci/push_to_github.sh b/tools/ci/push_to_github.sh
new file mode 100755 (executable)
index 0000000..6ea479a
--- /dev/null
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+# gitlab-ci script to push current tested revision (tag or branch) to github
+
+set -ex
+
+if [ -n "${CI_COMMIT_TAG}" ]; then
+    # for tags
+    git push github "${CI_COMMIT_TAG}"
+else
+    # for branches
+    git push github "${CI_COMMIT_SHA}:refs/heads/${CI_COMMIT_REF_NAME}"
+fi
+