diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ded50cf9ada2c24122c3d3964a16a394dcd5d973..256e0faa9cea4b650c21fa6be046d2dababbe758 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 @@ -42,3 +43,6 @@ build-frontend: artifacts: paths: - dist/email-recovery.tar.gz + +include: + - local: 'lib/gitlab/ci/templates/Jobs/Auto-Deploy-Pipelines.gitlab-ci.yml' 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 new file mode 100644 index 0000000000000000000000000000000000000000..d1a8172abab8851bcdfb6d1a0189a02529d0788e --- /dev/null +++ b/lib/gitlab/ci/templates/Jobs/Auto-Deploy-Pipelines.gitlab-ci.yml @@ -0,0 +1,70 @@ +.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