From 9842a7e2a4c94984f01ae826000e25f7fc21a508 Mon Sep 17 00:00:00 2001 From: Ryuuji Date: Wed, 3 Jun 2020 10:55:00 +0000 Subject: [PATCH] Update .gitlab-ci.yml --- .gitlab-ci.yml | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6b9da35..1e9a37b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,16 +1,28 @@ image: python:latest -services: - - mysql:latest - - postgres:latest - -cache: - paths: - - ~/.cache/pip/ - before_script: - - pip install -r requirements.txt + - apt-get update -y && apt-get upgrade -y -test: - script: - - python manage.py test +deploy: + ## Install ssh-agent if not already installed + - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client git -y )' + + ## Run ssh-agent (inside the build environment) + - eval $(ssh-agent -s) + + ## Add the SSH key stored in SSH_PRIVATE_KEY variable to the agent store + - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - + + ## Create the SSH directory and give it the right permissions + - mkdir -p ~/.ssh + - chmod 700 ~/.ssh + + ## Use ssh-keyscan to scan the keys of the private server + - ssh-keyscan "142.93.158.54" >> ~/.ssh/known_hosts + - chmod 644 ~/.ssh/known_hosts + + ## Sync the project to the deploy route + - apt-get install rsync -y + - rsync -rvz ./ deployer@142.93.158.54:/var/www/musiclist.danielcortes.xyz/server/ + - ssh deployer@142.93.158.54 '/var/www/musiclist.danielcortes.xyz/server/deploy.sh' +