From f4ee1ec772abce59ecf90a604774568d44d7969e Mon Sep 17 00:00:00 2001 From: Chen Yu Dong Date: Thu, 26 Oct 2023 11:14:51 +0800 Subject: [PATCH] ci: fix push to github (c9f8ec63) --- .gitlab-ci.yml | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 98e2d9cf..b7b59501 100755 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -56,11 +56,11 @@ push_master_to_github: only: - master - /^release\/v/ + - /^v\d+\.\d+/ # when: on_success image: $CI_DOCKER_REGISTRY/esp32-ci-env variables: - GIT_STRATEGY: clone - GITHUB_PUSH_REFS: refs/remotes/origin/release refs/remotes/origin/master + GIT_DEPTH: 0 before_script: [] script: - mkdir -p ~/.ssh @@ -70,15 +70,13 @@ 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/esp32-wifi-lib.git - # 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) - + # Ref: esp-idf tools/ci/push_to_github.sh + - | + if [ -n "${CI_COMMIT_TAG}" ]; then + git push github "${CI_COMMIT_TAG}" + else + git push github "${CI_COMMIT_SHA}:refs/heads/${CI_COMMIT_REF_NAME}" + fi include: - 'tools/ci/config/build.yml' - 'tools/ci/config/feature_test.yml'