diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 88d5caa..14156eb 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,6 +3,8 @@ stages: # List of stages for jobs, and their order of execution - test - deploy +image: debian + docker-build: # Use the official docker image. image: docker:latest @@ -24,10 +26,24 @@ docker-build: fi - docker build --pull -t "$CI_REGISTRY_IMAGE${tag}" . - docker push "$CI_REGISTRY_IMAGE${tag}" - # Run this job in a branch where a Dockerfile exists - rules: - - if: $CI_COMMIT_BRANCH - exists: - - Dockerfile - - if: $CI_COMMIT_BRANCH == "master" || $CI_COMMIT_BRANCH == "dev" - when: always + only: + - master + - dev + +before_script: + - apt-get update -qq + - apt-get install -qq git + # Setup SSH deploy keys + - 'which ssh-agent || ( apt-get install -qq openssh-client )' + - eval $(ssh-agent -s) + - ssh-add <(echo "$SSH_PRIVATE_KEY") + - mkdir -p ~/.ssh + - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config' + +deploy_staging: + type: deploy + script: + - ssh $SSH_SERVER "cd /root && docker-compose up -d bot && exit" + only: + - master + \ No newline at end of file