From 769c3e525f48f7cb2326109614082fbf0d022ae4 Mon Sep 17 00:00:00 2001 From: Kishan Takoordyal Date: Thu, 4 Mar 2021 19:34:57 +0400 Subject: [PATCH] add Gitlab CI/CD --- .gitlab-ci.yml | 17 +++++++++++++++++ buildScript.sh | 7 +++++++ 2 files changed, 24 insertions(+) create mode 100644 .gitlab-ci.yml create mode 100755 buildScript.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..59224dc --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,17 @@ +stages: + - deploy + +deploy: + stage: deploy + image: node:latest + before_script: + - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client git -y )' + - eval $(ssh-agent -s) + - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - + - mkdir -p ~/.ssh + - chmod 700 ~/.ssh + - ssh-keyscan repo.kinesis.games >> ~/.ssh/known_hosts + - chmod 644 ~/.ssh/known_hosts + - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config' + script: + - ssh ubuntu@kinesis.games "cd /var/www/proximity-demo/ && sudo bash buildScript.sh" diff --git a/buildScript.sh b/buildScript.sh new file mode 100755 index 0000000..efbe54c --- /dev/null +++ b/buildScript.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +git pull origin master +npm i +npm run-script build +chown -R root:www-data . +systemctl reload apache2