From 2cf6fa7a322c2d42d5fc4d3d49a0cb94ac9ded71 Mon Sep 17 00:00:00 2001 From: fox Date: Fri, 12 Feb 2021 18:01:21 +0300 Subject: [PATCH] CI/CD --- .gitlab-ci.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..824f5aa --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,27 @@ +image: python:latest + +stages: + - deploy + +.ssh: + before_script: + - 'which ssh-agent || ( apt update -y && apt install openssh-client -y )' + - 'which rsync || ( apt update -y && apt install rsync -y )' + - mkdir -p ~/.ssh + - eval $(ssh-agent -s) + - 'echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config' + - ssh-add <(echo $PRIVATE_KEY | base64 -d) + +.deploy: + stage: deploy + extends: .ssh + script: + - rsync -rlt --delete --exclude={'.env','.git','.gitignore'} ./ $REMOTE_USER@$REMOTE_HOST:$REMOTE_PATH/ + - ssh $REMOTE_USER@$REMOTE_HOST "cd $REMOTE_PATH && pipenv install" + - ssh $REMOTE_USER@$REMOTE_HOST "sudo systemctl restart $SYSTEMD_UNIT" + +deploy_prod: + extends: .deploy + environment: + name: production + url: https://thematdev.org \ No newline at end of file