diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index feed030401cabec71e59868127f1fd28cea95d09..4c5d0c9885c47e6a1cb5df8a0b8fa23bb2f54d2a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,89 +1,15 @@ -stages: - - deploy +variables: + APP_NAME: eCloud # Deploy stage -.deploy:theme: - image: ubuntu:focal - stage: deploy - before_script: - - mkdir $HOME/.ssh - - chmod 700 ~/.ssh - # cannot use GitLab variable type File and cp here because key format - # gets garbled somehow; this doesn't happen with echo - - 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 - script: - - echo "Deploying to $CI_ENVIRONMENT_NAME ($DEPLOYMENT_HOST)" - - ssh $SSH_USER@$DEPLOYMENT_HOST "git clone --depth 1 $CI_REPOSITORY_URL --branch $DEPLOYMENT_BRANCH --single-branch /tmp/${CI_JOB_ID}/eCloud && sudo rsync -avzh --chown www-data:www-data --delete --exclude '.git*' /tmp/${CI_JOB_ID}/eCloud ${DEPLOYMENT_PATH}/html/themes/ && rm -rf /tmp/${CI_JOB_ID} && docker exec -u www-data $CONTAINER_NAME /usr/local/bin/php /var/www/html/occ maintenance:theme:update" - -deploy:dev01: - extends: .deploy:theme - when: manual - only: - - /^dev\/.*$/ - - master - - main - environment: - name: dev/01 - url: https://dev.eeo.one/ - variables: - DEPLOYMENT_BRANCH: $CI_COMMIT_BRANCH - CONTAINER_NAME: dev01_nextcloud +include: + - project: 'e/infra/ecloud/nextcloud-apps/ci-templates' + ref: main + file: 'nc-apps-checkout-deploy.yml' -deploy:dev02: - extends: .deploy:theme - when: manual - only: - - /^dev\/.*$/ - - master - - main - environment: - name: dev/02 - url: https://ecloud02.dev.eeo.one - variables: - DEPLOYMENT_BRANCH: $CI_COMMIT_BRANCH - CONTAINER_NAME: dev02_nextcloud +.deploy:nextcloud-app-by-checkout: + script: + - ssh $SSH_USER@$DEPLOYMENT_HOST "git clone --depth 1 $CI_REPOSITORY_URL --branch $DEPLOYMENT_BRANCH --single-branch /tmp/${CI_JOB_ID}/${APP_NAME} && sudo rsync -avzh --chown www-data:www-data --delete --exclude '.git*' /tmp/${CI_JOB_ID}/${eCloud} ${DEPLOYMENT_PATH}/html/themes/ && rm -rf /tmp/${CI_JOB_ID} && docker exec -u www-data $CONTAINER_NAME /usr/local/bin/php /var/www/html/occ maintenance:theme:update" -deploy:dev03: - extends: .deploy:theme - when: manual - only: - - /^dev\/.*$/ - - master - - 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:theme - when: manual - only: - - master - - main - - production - environment: - name: staging/01 - url: https://eeo.one - variables: - DEPLOYMENT_BRANCH: $CI_COMMIT_BRANCH - CONTAINER_NAME: nextcloud -deploy:production: - extends: .deploy:theme - when: manual - only: - - production - environment: - name: prod/01 - url: https://ecloud.global - variables: - DEPLOYMENT_BRANCH: $CI_COMMIT_BRANCH - CONTAINER_NAME: nextcloud