Testing building with version number in OpenShift

This commit is contained in:
Erik Tiekstra
2021-09-09 13:33:41 +02:00
parent af43db3aba
commit 29c97edacb
9 changed files with 145 additions and 5 deletions

58
tools/build-os.sh Normal file
View File

@@ -0,0 +1,58 @@
#!/bin/bash
#
# Script to build the application and creating a version number depending on build
# ----------------------------------
# COLORS
# ----------------------------------
NOCOLOR='\033[0m'
RED='\033[0;31m'
GREEN='\033[0;32m'
ORANGE='\033[0;33m'
CYAN='\033[0;36m'
YELLOW='\033[1;33m'
BRANCH=$(git rev-parse --abbrev-ref HEAD)
version=${version:-$BRANCH}
config=${config:-prod}
while [ $# -gt 0 ]; do
if [[ $1 == *"--"* ]]; then
param="${1/--/}"
declare $param="$2"
# echo $1 $2 // Optional to see the parameter:value result
fi
shift
done
# ----------------------------------
# UPDATING VERSION
# ----------------------------------
echo -e "${CYAN}Setting VERSION to ${version} inside assets directory${NOCOLOR}"
rm -f apps/mina-sidor-fa/src/assets/VERSION.md
touch apps/mina-sidor-fa/src/assets/VERSION.md
echo $version > apps/mina-sidor-fa/src/assets/VERSION.md
echo -e "${GREEN}VERSION set to ${version}${NOCOLOR}"
# ----------------------------------
# BUILD APPLICATION
# ----------------------------------
if [ $config = "prod" ]; then
echo -e "${CYAN}Running npm run build -- --prod${NOCOLOR}"
npm run build -- --prod
echo -e "${GREEN}Application built ${VERSION}${NOCOLOR}"
exit
else
echo -e "${CYAN}Running npm run build:${CONFIG}${NOCOLOR}"
npm run build:$config
echo -e "${GREEN}Application built ${VERSION}${NOCOLOR}"
exit
fi

62
tools/serve-os.sh Normal file
View File

@@ -0,0 +1,62 @@
#!/bin/bash
#
# Script to serve the application and creating a version number depending on build
# ----------------------------------
# COLORS
# ----------------------------------
NOCOLOR='\033[0m'
RED='\033[0;31m'
GREEN='\033[0;32m'
ORANGE='\033[0;33m'
CYAN='\033[0;36m'
YELLOW='\033[1;33m'
BRANCH=$(git rev-parse --abbrev-ref HEAD)
version=${version:-$BRANCH}
config=${config:-prod}
while [ $# -gt 0 ]; do
if [[ $1 == *"--"* ]]; then
param="${1/--/}"
declare $param="$2"
# echo $1 $2 // Optional to see the parameter:value result
fi
shift
done
# ----------------------------------
# UPDATING VERSION
# ----------------------------------
echo -e "${CYAN}Setting VERSION to ${version} inside assets directory${NOCOLOR}"
rm -f apps/mina-sidor-fa/src/assets/VERSION.md
touch apps/mina-sidor-fa/src/assets/VERSION.md
echo $version > apps/mina-sidor-fa/src/assets/VERSION.md
echo -e "${GREEN}VERSION set to ${version}${NOCOLOR}"
# ----------------------------------
# BUILD APPLICATION
# ----------------------------------
if [ $config = "prod" ]; then
echo -e "${CYAN}Running npm run start -- --prod${NOCOLOR}"
npm run start -- --prod
echo -e "${GREEN}Application started${NOCOLOR}"
exit
elif [ $config = 'local' ]; then
echo -e "${CYAN}Running npm run start${NOCOLOR}"
npm run start
echo -e "${GREEN}Application started${NOCOLOR}"
exit
else
echo -e "${CYAN}Running npm run start:${CONFIG}${NOCOLOR}"
npm run start:$config
echo -e "${GREEN}Application started${NOCOLOR}"
exit
fi