-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathpre.sh
67 lines (61 loc) · 1.51 KB
/
pre.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env bash
#
#
# Update deployment paths, prefixes
#
deployPaths()
{
local DEPLOY_BRANCH=$1
local CONTAINER_BUILD_ENV=$2
DEPLOY_PATH_PREFIX=""
DEPLOY_STAGE="Stable"
# Note: Deprecated beta-preview prefixes. Temporarily left because they provide an alternative for prefixing paths.
if [[ $CONTAINER_BUILD_ENV == "true" ]]; then
DEPLOY_STAGE="Preview"
DEPLOY_PATH_PREFIX=/beta
DEPLOY_PATH_LINK_PREFIX=/preview
fi
echo UI_DEPLOY_PATH_PREFIX="$DEPLOY_PATH_PREFIX" >> ./.env.production.local
echo UI_DEPLOY_PATH_LINK_PREFIX="$DEPLOY_PATH_LINK_PREFIX" >> ./.env.production.local
echo "\"${DEPLOY_STAGE}\" build stage config for branch \"${DEPLOY_BRANCH}\"..."
printf "Deploy path prefix ... ${GREEN}UI_DEPLOY_PATH_PREFIX=$DEPLOY_PATH_PREFIX${NOCOLOR}\n"
}
#
#
# Clean directories
#
version()
{
UI_VERSION="$(node -p 'require(`./package.json`).version').$(git rev-parse --short HEAD)"
printf "Version... ${GREEN}UI_VERSION=$UI_VERSION${NOCOLOR}\n"
echo UI_VERSION="$UI_VERSION" >> ./.env.production.local
}
#
#
# Clean directories
#
clean()
{
echo "Cleaning build directories, files..."
rm -rf -- ./dist
rm -rf -- ./build
rm -rf -- ./public/apps
rm -f ./.env.production.local
}
#
#
# main()
#
{
BLUE="\e[34m"
RED="\e[31m"
GREEN="\e[32m"
YELLOW="\e[33m"
NOCOLOR="\e[39m"
clean
version
# Note: See GitHub actions, and Container Build environment variables
# - GitHub actions: BRANCH, BETA
# - Container Build: BETA
deployPaths "${BRANCH:-local}" "${BETA:-local env}"
}