From 0fc845bfc500c18878d47ae746cc0a463d07f1a9 Mon Sep 17 00:00:00 2001 From: Joey Hafner Date: Thu, 10 Feb 2022 17:25:26 +0000 Subject: [PATCH] Deploy to server via SSH --- .gitlab-ci.yml | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index dfefb03..72676c0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,9 +1,18 @@ -stages: - - deploy +before_script: + # update and install git + - apt-get update -qq + - apt-get install -qq git + # configure SSH 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\tStrickHostKeyChecking no\n\n" > ~/.ssh/config' + server-deploy: stage: deploy only: - "server/" script: - - echo "I want to SSH to server" + - ssh joey@joey-server "cd /home/joey/docker_config && git pull origin master && exit"