From bc8a84e9e47e5903930b2d534869644dcce14ea8 Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Thu, 16 Aug 2018 11:04:28 +1000 Subject: [PATCH] ci: Fix spurious pipeline failure when deploying a tag to GitHub Everything succeeds, but because [ -z ${CI_COMMIT_TAG} ] on the last line returns non-zero, it fails the job. --- .gitlab-ci.yml | 4 +--- tools/ci/push_to_github.sh | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) create mode 100755 tools/ci/push_to_github.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 79af5be08a..78a3072a80 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -291,9 +291,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 diff --git a/tools/ci/push_to_github.sh b/tools/ci/push_to_github.sh new file mode 100755 index 0000000000..6ea479ad6f --- /dev/null +++ b/tools/ci/push_to_github.sh @@ -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 +