Enable sandbox mode with CICD deply strategy
This commit is contained in:
@@ -3,28 +3,75 @@ source ~/bash_config.sh
|
||||
|
||||
# Requirements
|
||||
# Node v18
|
||||
function build_static(){
|
||||
function build_production(){
|
||||
#Global ENV VAR: BUILD_NAME
|
||||
#Global ENV VAR: VITE_API_URL
|
||||
nvm use 18
|
||||
npm install --force 2>/dev/null
|
||||
set -x
|
||||
cat dotenv > .env
|
||||
npm run build 2>/dev/null
|
||||
cp htaccess dist/.htaccess
|
||||
zip -r $BUILD_NAME.zip dist/
|
||||
set +x
|
||||
|
||||
# Production API
|
||||
echo "VITE_API_URL=\"https://api.etaviaporte.com/api\"" > .env
|
||||
echo "VITE_MAP_KEY=\"${CICD_MAP_KEY}\"" >> .env
|
||||
|
||||
set -x
|
||||
npm run build 2>/dev/null
|
||||
cp htaccess dist/.htaccess
|
||||
zip -r ${BUILD_NAME}.zip dist/
|
||||
set +x
|
||||
}
|
||||
|
||||
function deploy(){
|
||||
function deploy_production(){
|
||||
# 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 ./$BUILD_NAME.zip "$SYSTEM_HOSTINGER_HOSTNAME":~/$INSTALL_PATH
|
||||
scp ./scripts/ssh_install_script.sh "$SYSTEM_HOSTINGER_HOSTNAME":~/$INSTALL_PATH
|
||||
ssh "$SYSTEM_HOSTINGER_HOSTNAME" "cd ~/$INSTALL_PATH && bash ssh_install_script.sh && rm ssh_install_script.sh"
|
||||
scp ./${BUILD_NAME}.zip "${SYSTEM_HOSTINGER_HOSTNAME}":~/${INSTALL_PATH}
|
||||
scp ./scripts/ssh_install_script.sh "${SYSTEM_HOSTINGER_HOSTNAME}":~/${INSTALL_PATH}
|
||||
ssh "${SYSTEM_HOSTINGER_HOSTNAME}" "cd ~/${INSTALL_PATH} && bash ssh_install_script.sh && rm ssh_install_script.sh"
|
||||
set +x
|
||||
}
|
||||
|
||||
function build_sandbox(){
|
||||
# Global Env Var: CICD_REGISTRY_HOST
|
||||
# Global Env Var: SANDBOX_HOMEPAGE
|
||||
CONTAINER_NAME="console"
|
||||
CONTAINER_VERSION="sandbox"
|
||||
|
||||
# Sandbox API
|
||||
echo "VITE_API_URL=\"https://dev.api.etaviaporte.com/api\"" > .env
|
||||
echo "VITE_MAP_KEY=\"${CICD_MAP_KEY}\"" >> .env
|
||||
|
||||
set -x
|
||||
nvm use 18
|
||||
npm install
|
||||
npm run build
|
||||
|
||||
npm run build 2>/dev/null
|
||||
cp htaccess dist/.htaccess
|
||||
|
||||
docker rmi -f "${CICD_REGISTRY_HOST}/${CONTAINER_NAME}:${CONTAINER_VERSION}"
|
||||
docker buildx build --no-cache -t "${CICD_REGISTRY_HOST}/${CONTAINER_NAME}:${CONTAINER_VERSION}" ./
|
||||
set +x
|
||||
}
|
||||
|
||||
function upload_sandbox(){
|
||||
# Global Env Var: CICD_REGISTRY_HOST
|
||||
# Global Env Var: CICD_REGISTRY_USER
|
||||
# Global Env Var: CICD_REGISTRY_TOKEN
|
||||
CONTAINER_NAME="console"
|
||||
CONTAINER_VERSION="sandbox"
|
||||
|
||||
docker login ${CICD_REGISTRY_HOST} -u ${CICD_REGISTRY_USER} -p ${CICD_REGISTRY_TOKEN}
|
||||
set -x
|
||||
docker push "${CICD_REGISTRY_HOST}/${CONTAINER_NAME}:${CONTAINER_VERSION}"
|
||||
set +x
|
||||
}
|
||||
|
||||
function deploy_sandbox(){
|
||||
#Global ENV VAR: CICD_CONSOLE_SANDBOX_WEBHOOK
|
||||
set -x
|
||||
curl -X POST "${CICD_CONSOLE_SANDBOX_WEBHOOK}"
|
||||
set +x
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user