From c5436739b14cfce064f5853468cc12785608b53e Mon Sep 17 00:00:00 2001 From: Fazle Rabbi Date: Thu, 19 May 2022 12:30:23 +0600 Subject: [PATCH 1/7] add Auto-Deploy-Pipelines.gitlab-ci.yml --- .../Auto-Deploy-Pipelines.gitlab-ci.yml | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 lib/gitlab/ci/templates/Auto-Deploy-Pipelines.gitlab-ci.yml diff --git a/lib/gitlab/ci/templates/Auto-Deploy-Pipelines.gitlab-ci.yml b/lib/gitlab/ci/templates/Auto-Deploy-Pipelines.gitlab-ci.yml new file mode 100644 index 0000000..f3ec6b8 --- /dev/null +++ b/lib/gitlab/ci/templates/Auto-Deploy-Pipelines.gitlab-ci.yml @@ -0,0 +1,73 @@ +stages: + - deploy + +.deploy:nextcloud-app: + image: ubuntu:focal + stage: deploy + dependencies: + - build-frontend + before_script: + - mkdir $HOME/.ssh + - chmod 700 ~/.ssh + - echo "$SSH_PRIVATE_KEY_ED" > $HOME/.ssh/id_ed25519 + - echo "$SSH_PUBKEY_ED" > $HOME/.ssh/id_ed25519.pub + - echo "$SSH_KNOWN_HOSTS" > $HOME/.ssh/known_hosts + - chmod 600 ~/.ssh/id_ed25519 + - chmod 644 ~/.ssh/known_hosts ~/.ssh/id_ed25519.pub + - apt-get update && apt-get install -y openssh-client rsync + script: + - echo "Deploying $CI_PROJECT_NAME of $CI_PROJECT_PATH_SLUG to $CI_ENVIRONMENT_NAME ($DEPLOYMENT_HOST)" + - rsync -avzh dist/ $SSH_USER@$DEPLOYMENT_HOST:/tmp/${CI_JOB_ID} + - ssh $SSH_USER@$DEPLOYMENT_HOST "sudo rsync -avzh --chown www-data:www-data --delete /tmp/${CI_JOB_ID}/$CI_PROJECT_NAME ${DEPLOYMENT_PATH}/html/custom_apps/ && rm -rf /tmp/${CI_JOB_ID} && sudo docker exec -u www-data $CONTAINER_NAME /var/www/html/occ app:enable $CI_PROJECT_NAME" + +deploy:dev01: + extends: .deploy:nextcloud-app + when: manual + only: + - /^dev\/.*$/ + - main + environment: + name: dev/01 + url: https://dev.eeo.one/ + variables: + DEPLOYMENT_BRANCH: $CI_COMMIT_BRANCH + CONTAINER_NAME: dev01_nextcloud + +deploy:dev02: + extends: .deploy:nextcloud-app + when: manual + only: + - /^dev\/.*$/ + - main + environment: + name: dev/02 + url: https://ecloud02.dev.eeo.one + variables: + DEPLOYMENT_BRANCH: $CI_COMMIT_BRANCH + CONTAINER_NAME: dev02_nextcloud + +deploy:dev03: + extends: .deploy:nextcloud-app + when: manual + only: + - /^dev\/.*$/ + - main + environment: + name: dev/03 + url: https://ecloud03.dev.eeo.one + variables: + DEPLOYMENT_BRANCH: $CI_COMMIT_BRANCH + CONTAINER_NAME: dev03_nextcloud + +deploy:staging: + extends: .deploy:nextcloud-app + when: manual + only: + - main + - production + environment: + name: staging/01 + url: https://eeo.one + variables: + DEPLOYMENT_BRANCH: $CI_COMMIT_BRANCH + CONTAINER_NAME: nextcloud -- GitLab From 438568ac56f622f5216af56e48445b2a7ed3f366 Mon Sep 17 00:00:00 2001 From: Fazle Rabbi Date: Thu, 19 May 2022 12:31:19 +0600 Subject: [PATCH 2/7] include Auto-Deploy-Pipelines --- .gitlab-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ded50cf..41f7234 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -42,3 +42,5 @@ build-frontend: artifacts: paths: - dist/email-recovery.tar.gz + +include: 'https://company.com/autodevops-template.yml' -- GitLab From 13f771b5875f7e04232683d6854b6c0f31373507 Mon Sep 17 00:00:00 2001 From: Fazle Rabbi Date: Thu, 19 May 2022 12:34:15 +0600 Subject: [PATCH 3/7] =?UTF-8?q?fix=20include=20file=20name=20=F0=9F=A4=A6?= =?UTF-8?q?=E2=80=8D=E2=99=82=EF=B8=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 41f7234..782afc1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -43,4 +43,4 @@ build-frontend: paths: - dist/email-recovery.tar.gz -include: 'https://company.com/autodevops-template.yml' +include: Auto-Deploy-Pipelines.gitlab-ci.yml -- GitLab From be32bd48a169dfee41c2a47299afa75aeffe009c Mon Sep 17 00:00:00 2001 From: Fazle Rabbi Date: Thu, 19 May 2022 12:37:30 +0600 Subject: [PATCH 4/7] fix path for include as it needs '/templates/' before --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 782afc1..b8f249e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -43,4 +43,4 @@ build-frontend: paths: - dist/email-recovery.tar.gz -include: Auto-Deploy-Pipelines.gitlab-ci.yml +include: '/templates/Auto-Deploy-Pipelines.gitlab-ci.yml' -- GitLab From 91fdf9e79d9ded074a295b56315d67abff8671e1 Mon Sep 17 00:00:00 2001 From: Fazle Rabbi Date: Thu, 19 May 2022 13:09:52 +0600 Subject: [PATCH 5/7] [skip ci] move Auto-Deploy-Pipelines to Jobs to satisfy lint --- .../ci/templates/{ => Jobs}/Auto-Deploy-Pipelines.gitlab-ci.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename lib/gitlab/ci/templates/{ => Jobs}/Auto-Deploy-Pipelines.gitlab-ci.yml (100%) diff --git a/lib/gitlab/ci/templates/Auto-Deploy-Pipelines.gitlab-ci.yml b/lib/gitlab/ci/templates/Jobs/Auto-Deploy-Pipelines.gitlab-ci.yml similarity index 100% rename from lib/gitlab/ci/templates/Auto-Deploy-Pipelines.gitlab-ci.yml rename to lib/gitlab/ci/templates/Jobs/Auto-Deploy-Pipelines.gitlab-ci.yml -- GitLab From 091d7976c4bdd0cf322b8741f5b4b96907ffe089 Mon Sep 17 00:00:00 2001 From: Fazle Rabbi Date: Thu, 19 May 2022 13:23:43 +0600 Subject: [PATCH 6/7] [skip ci] remove stage info from template --- .../ci/templates/Jobs/Auto-Deploy-Pipelines.gitlab-ci.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/gitlab/ci/templates/Jobs/Auto-Deploy-Pipelines.gitlab-ci.yml b/lib/gitlab/ci/templates/Jobs/Auto-Deploy-Pipelines.gitlab-ci.yml index f3ec6b8..d1a8172 100644 --- a/lib/gitlab/ci/templates/Jobs/Auto-Deploy-Pipelines.gitlab-ci.yml +++ b/lib/gitlab/ci/templates/Jobs/Auto-Deploy-Pipelines.gitlab-ci.yml @@ -1,6 +1,3 @@ -stages: - - deploy - .deploy:nextcloud-app: image: ubuntu:focal stage: deploy -- GitLab From d275e4f112e9fcfdd4625c49ae1ba607bbd58ea1 Mon Sep 17 00:00:00 2001 From: Fazle Rabbi Date: Thu, 19 May 2022 13:27:04 +0600 Subject: [PATCH 7/7] add deployment state and include template --- .gitlab-ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b8f249e..256e0fa 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,6 +2,7 @@ stages: - prepare - test - build + - deploy default: image: node:15.14.0-stretch @@ -43,4 +44,5 @@ build-frontend: paths: - dist/email-recovery.tar.gz -include: '/templates/Auto-Deploy-Pipelines.gitlab-ci.yml' +include: + - local: 'lib/gitlab/ci/templates/Jobs/Auto-Deploy-Pipelines.gitlab-ci.yml' -- GitLab