Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2c27a075 authored by Arnau Vàzquez's avatar Arnau Vàzquez
Browse files

Merge branch 'dev/auto-deploy-pipe' into 'master'

Use template for deployments

See merge request !64
parents a833d85e 563e8d1a
Loading
Loading
Loading
Loading
+9 −83
Original line number Diff line number Diff line
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"
include:
  - project: 'e/infra/ecloud/nextcloud-apps/ci-templates'
    ref: main
    file: 'nc-apps-checkout-deploy.yml'

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

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