Add deploy CI target
Change-Id: If2f954fb0556f6306ff26520d985ac903a964993
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 8450e46..23bd552 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -53,3 +53,25 @@
- prove --verbose t
- end_section run_derekovecs-server
+deploy:
+ rules:
+ - if: $CI_COMMIT_TAG =~ /.+/
+ variables:
+ VID: $CI_COMMIT_TAG
+ - when: manual
+ variables:
+ VID: $CI_COMMIT_BRANCH-$CI_COMMIT_SHORT_SHA
+ stage: deploy
+ before_script:
+ - source `find .. -name section_helper.sh`
+ - start_section install_linux_packages "Installing missing Linux packages"
+ - 'command -v ssh-agent >/dev/null || apt-get install openssh-client -y'
+ - mkdir -p ~/.ssh
+ - chmod 700 ~/.ssh
+ - eval $(ssh-agent -s)
+ - chmod 400 "$SSH_PRIVATE_KEY"
+ - ssh-add "$SSH_PRIVATE_KEY"
+ - end_section install_linux_packages
+ script:
+ - echo "This is a manual job which doesn't start automatically, and the pipeline can complete without it starting."
+ - ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null $DEPLOY_HOST "cd /opt/korap/derekovecs && git stash && git pull && cpanm --installdeps . && cpanm . && rm -rf _Inline && sudo systemctl restart derekovecs"