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