From 3cafbe3cf9d435bd4d577328609c2df26cdf2396 Mon Sep 17 00:00:00 2001 From: Dmitriy Safronov Date: Tue, 20 Apr 2021 00:28:44 +0300 Subject: [PATCH 1/5] .gitignore --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b180b8f --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/roles/ +/.idea/ +*.iml -- GitLab From 02152db22e71c4a13212ee26e3522a6068f90013 Mon Sep 17 00:00:00 2001 From: Dmitriy Safronov Date: Tue, 20 Apr 2021 00:29:02 +0300 Subject: [PATCH 2/5] gitlab-ci.yml --- gitlab-ci.yml | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 gitlab-ci.yml diff --git a/gitlab-ci.yml b/gitlab-ci.yml new file mode 100644 index 0000000..b983efc --- /dev/null +++ b/gitlab-ci.yml @@ -0,0 +1,34 @@ +--- + +# VARIABLES +variables: + GIT_DEPTH: 1 + +########################################################################################################## + +## PIPELINE DEFINITION +stages: + - sync + +########################################################################################################## + +### SYNC SECTION +sync: + image: $GIT_IMAGE + stage: sync + except: + refs: + - merge_requests + only: + refs: + - master + script: + - git config --global credential.helper store && touch ~/.git-credentials + - echo "https://${GIT_LOGIN}:${GIT_PASSWORD}@$(echo ${GIT_URL} | sed -r 's#([^/])/[^/].*#\1#' | sed -e 's|https://||g')" >> ~/.git-credentials || true + - echo "https://gitlab-ci-token:${CI_BUILD_TOKEN}@${CI_SERVER_HOST}" >> ~/.git-credentials || true + - ( eval $(ssh-agent -s); echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null && mkdir -p ~/.ssh && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config ) || true + - git checkout master + - git remote add upstream "${GIT_URL}" # https://github.com/southbridgeio/kubespray.git + - git fetch upstream + - git pull upstream "${GIT_UPSTGREAM_BRANCH}" # master + - git push -- GitLab From fa4bd80defd54db504e19a41440377dc44734b55 Mon Sep 17 00:00:00 2001 From: Dmitriy Safronov Date: Tue, 20 Apr 2021 00:32:02 +0300 Subject: [PATCH 3/5] gitlab-ci.yml --- gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitlab-ci.yml b/gitlab-ci.yml index b983efc..2a50d54 100644 --- a/gitlab-ci.yml +++ b/gitlab-ci.yml @@ -25,7 +25,7 @@ sync: script: - git config --global credential.helper store && touch ~/.git-credentials - echo "https://${GIT_LOGIN}:${GIT_PASSWORD}@$(echo ${GIT_URL} | sed -r 's#([^/])/[^/].*#\1#' | sed -e 's|https://||g')" >> ~/.git-credentials || true - - echo "https://gitlab-ci-token:${CI_BUILD_TOKEN}@${CI_SERVER_HOST}" >> ~/.git-credentials || true + - echo "https://gitlab-ci-token:${CI_ACCESS_TOKEN}@${CI_SERVER_HOST}" >> ~/.git-credentials || true - ( eval $(ssh-agent -s); echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null && mkdir -p ~/.ssh && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config ) || true - git checkout master - git remote add upstream "${GIT_URL}" # https://github.com/southbridgeio/kubespray.git -- GitLab From 2a9f19dd7a5ad03b78e3ad1a5d03cf4b2c8bd574 Mon Sep 17 00:00:00 2001 From: Dmitriy Safronov Date: Tue, 20 Apr 2021 00:35:30 +0300 Subject: [PATCH 4/5] gitlab-ci.yml --- gitlab-ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gitlab-ci.yml b/gitlab-ci.yml index 2a50d54..6cdebee 100644 --- a/gitlab-ci.yml +++ b/gitlab-ci.yml @@ -24,11 +24,11 @@ sync: - master script: - git config --global credential.helper store && touch ~/.git-credentials - - echo "https://${GIT_LOGIN}:${GIT_PASSWORD}@$(echo ${GIT_URL} | sed -r 's#([^/])/[^/].*#\1#' | sed -e 's|https://||g')" >> ~/.git-credentials || true - echo "https://gitlab-ci-token:${CI_ACCESS_TOKEN}@${CI_SERVER_HOST}" >> ~/.git-credentials || true + - ( test -n "${GIT_LOGIN}" && test -n "${GIT_PASSWORD}" ) && echo "https://${GIT_LOGIN}:${GIT_PASSWORD}@$(echo ${GIT_URL} | sed -r 's#([^/])/[^/].*#\1#' | sed -e 's|https://||g')" >> ~/.git-credentials || true - ( eval $(ssh-agent -s); echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null && mkdir -p ~/.ssh && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config ) || true - git checkout master - - git remote add upstream "${GIT_URL}" # https://github.com/southbridgeio/kubespray.git + - git remote add upstream "${GIT_URL}" - git fetch upstream - - git pull upstream "${GIT_UPSTGREAM_BRANCH}" # master + - git pull upstream "${GIT_UPSTGREAM_BRANCH}" - git push -- GitLab From bc7844ce2b65ed855e381a44cab5b70fa366b138 Mon Sep 17 00:00:00 2001 From: Dmitriy Safronov Date: Tue, 20 Apr 2021 00:43:08 +0300 Subject: [PATCH 5/5] gitlab-ci.yml --- gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitlab-ci.yml b/gitlab-ci.yml index 6cdebee..776c9af 100644 --- a/gitlab-ci.yml +++ b/gitlab-ci.yml @@ -24,7 +24,7 @@ sync: - master script: - git config --global credential.helper store && touch ~/.git-credentials - - echo "https://gitlab-ci-token:${CI_ACCESS_TOKEN}@${CI_SERVER_HOST}" >> ~/.git-credentials || true + - echo "https://${PROJECT_ACCESS_TOKEN_USERNAME}:${PROJECT_ACCESS_TOKEN}@${CI_SERVER_HOST}" >> ~/.git-credentials || true - ( test -n "${GIT_LOGIN}" && test -n "${GIT_PASSWORD}" ) && echo "https://${GIT_LOGIN}:${GIT_PASSWORD}@$(echo ${GIT_URL} | sed -r 's#([^/])/[^/].*#\1#' | sed -e 's|https://||g')" >> ~/.git-credentials || true - ( eval $(ssh-agent -s); echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null && mkdir -p ~/.ssh && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config ) || true - git checkout master -- GitLab