From 97667077e1116653c4c7d47c3f6611d730e74f2f Mon Sep 17 00:00:00 2001 From: Chris Lowis Date: Tue, 13 Nov 2018 20:19:19 +0000 Subject: [PATCH] Attempt to deploy site @chris has setup a server[1] and added the public half of a key pair generated using `ssh-keygen -o -t rsa -b 4096` as per the instructions on docs.gitlab.com[2]. The `before_script` was taken from the same instructions. I set the two variables SSH_PRIVATE_KEY and SSH_KNOWN_HOSTS in the CI/CD settings[3]. To see if this works I'm calling `rsync` in the `script` section of the deploy stage, using the dry-run option, `-n`. [1] https://git.coop/cotech/website/issues/4#note_9890 [2] https://docs.gitlab.com/ee/ci/ssh_keys/#ssh-keys-when-using-the-docker-executor [3] https://git.coop/cotech/website/settings/ci_cd --- .gitlab-ci.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 70b17a2..f2bff6c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,6 +5,13 @@ variables: LC_ALL: C.UTF-8 before_script: + - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )' + - eval $(ssh-agent -s) + - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null + - mkdir -p ~/.ssh + - chmod 700 ~/.ssh + - echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts + - chmod 644 ~/.ssh/known_hosts - bundle install test: @@ -21,6 +28,7 @@ pages: stage: deploy script: - bundle exec jekyll build -d public + - rsync -anv public/ cotech@webarch2.co.uk:~/sites/default/ artifacts: paths: - public