feat(CI): Adding automatic deployment to hostinger
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -26,3 +26,5 @@ coverage
|
|||||||
*.njsproj
|
*.njsproj
|
||||||
*.sln
|
*.sln
|
||||||
*.sw?
|
*.sw?
|
||||||
|
scripts/env.sh
|
||||||
|
**.zip
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
stages:
|
stages:
|
||||||
- build
|
- build
|
||||||
|
- deploy
|
||||||
|
|
||||||
variables:
|
variables:
|
||||||
PIPELINE_WORK_DIR: "./"
|
PIPELINE_WORK_DIR: "./"
|
||||||
@@ -22,3 +23,10 @@ build-job:
|
|||||||
only:
|
only:
|
||||||
- master
|
- master
|
||||||
|
|
||||||
|
deploy-job:
|
||||||
|
stage: deploy
|
||||||
|
script:
|
||||||
|
- . ./scripts/ci_functions.sh
|
||||||
|
- deploy
|
||||||
|
only:
|
||||||
|
- master
|
||||||
|
|||||||
@@ -13,3 +13,16 @@ function build_static(){
|
|||||||
zip -r $BUILD_NAME.zip dist/
|
zip -r $BUILD_NAME.zip dist/
|
||||||
set +x
|
set +x
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function deploy(){
|
||||||
|
# Global Env Var: SYSTEM_HOSTINGER_HOSTNAME
|
||||||
|
# Global Env Var: SYSTEM_HOSTINGER_SSH_USERNAME
|
||||||
|
# Global Env Var: SYSTEM_HOSTINGER_SSH_PORT
|
||||||
|
# Global Env Var: BUILD_NAME
|
||||||
|
INSTALL_PATH="public_html/subdomains/console/"
|
||||||
|
set -x
|
||||||
|
scp -i ~/.ssh/id_rsa -P $SYSTEM_HOSTINGER_SSH_PORT ./$BUILD_NAME.zip "$SYSTEM_HOSTINGER_SSH_USERNAME"@"$SYSTEM_HOSTINGER_HOSTNAME":~/$INSTALL_PATH
|
||||||
|
scp -i ~/.ssh/id_rsa -P $SYSTEM_HOSTINGER_SSH_PORT ./scripts/ssh_install_script.sh "$SYSTEM_HOSTINGER_SSH_USERNAME"@"$SYSTEM_HOSTINGER_HOSTNAME":~/$INSTALL_PATH
|
||||||
|
ssh -i ~/.ssh/id_rsa -p $SYSTEM_HOSTINGER_SSH_PORT "$SYSTEM_HOSTINGER_SSH_USERNAME"@"$SYSTEM_HOSTINGER_HOSTNAME" "cd ~/$INSTALL_PATH && bash ssh_install_script.sh && rm ssh_install_script.sh"
|
||||||
|
set +x
|
||||||
|
}
|
||||||
|
|||||||
25
scripts/ssh_install_script.sh
Normal file
25
scripts/ssh_install_script.sh
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
#! /bin/bash
|
||||||
|
# Execute from Hostinger machine
|
||||||
|
ZIP_FILE="enruta_web_dashboard.zip"
|
||||||
|
INSTALL_PATH="public_html/subdomains/console/"
|
||||||
|
|
||||||
|
if [[ -e "$ZIP_FILE" ]]; then
|
||||||
|
cd ~/$INSTALL_PATH
|
||||||
|
# Delete previous revision
|
||||||
|
rm -rf assets/ dist/ images/ .htaccess favicon.ico index.html
|
||||||
|
# Unzip new revision and install
|
||||||
|
unzip $ZIP_FILE
|
||||||
|
mv dist/* .
|
||||||
|
mv dist/.htaccess .
|
||||||
|
# Remove garbage
|
||||||
|
rm -rf dist/
|
||||||
|
rm $ZIP_FILE
|
||||||
|
# Update revision date
|
||||||
|
date > updated_at
|
||||||
|
else
|
||||||
|
echo "Zip file not available or renamed!"
|
||||||
|
exit -1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user