This repository has been archived by the owner on May 14, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathbuild.sh
120 lines (107 loc) · 2.39 KB
/
build.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/usr/bin/env bash
usage="\n$(basename "$0") [-d|--debug] [-m|--magentoVersion] [-t|--theme] [-b|--buildID] -- deploy script.\n
\n
where:
-h show the help text\n
-d|--debug Debug mode. Prompts before proceeding to script.\n
-m|--magentoVersion Magento version (at least specify 1 or 2).\n
-t|--theme Theme to be compiled. Blank for no compilation.\n
-b|--buildID Build number (placed in file: app/design/build)\n\n
ENVIRONMENT VARIABLES:\n
MYSQL_USER (default: root)\n
MYSQL_PASSWORD (default: [[empty]])\n\n
To run this script, you must be in the folder that contains a scripts/ folder (where this file is stored), and a src/ folder."
DEBUG=0
THEME=""
while [[ $# -gt 1 ]]
do
key="$1"
case $key in
-d|--debug)
DEBUG=1
shift
;;
-h|--help)
echo "$usage"
exit
shift
;;
-m|--magentoVersion)
MAGENTO_VERSION="$2"
shift
;;
--mysqlHost)
MYSQL_HOST="$2"
shift
;;
-t|--theme)
THEME="$2"
shift
;;
-b|--buildID)
BUILD_ID="$2"
shift
;;
--sentryOrg)
SENTRY_ORG="$2"
shift
;;
--sentryProjectSlug)
SENTRY_PROJECT_SLUG="$2"
shift
;;
--sentryToken)
SENTRY_TOKEN="$2"
shift
;;
-c|--commit)
COMMIT=$2
shift
;;
--repository)
REPOSITORY=$2
shift
;;
--pipelineID)
PIPELINE_ID=$2
shift
;;
*)
;;
esac
shift
done
if [ -z ${MYSQL_HOST+x} ]; then
MYSQL_HOST="127.0.0.1"
fi
if [ -z ${MAGENTO_VERSION+x} ]; then
MAGENTO_VERSION="2.2"
fi
if [ -z ${THEME+x} ]; then
THEME="flow"
fi
if [ -z ${DEBUG+x} ]; then
DEBUG=0
fi
export DEBUG=${DEBUG}
export THEME=${THEME}
export MYSQL_HOST=${MYSQL_HOST}
export MAGENTO_VERSION=${MAGENTO_VERSION}
export BUILD_ID=${BUILD_ID}
export PIPELINE_ID=${PIPELINE_ID}
# Include the directory iterator function
source scripts/utilities/include.sh
source scripts/utilities/php.sh
set -x
if [ ! -z "$SENTRY_ORG" ]; then
curl https://sentry.io/api/0/organizations/${SENTRY_ORG}/releases/ \
-X POST \
-H 'Authorization: Bearer '${SENTRY_TOKEN} \
-H 'Content-Type: application/json' \
-d '{"version": "'${PIPELINE_ID}'","id": "'${PIPELINE_ID}'","refs":[{"commit":"'${COMMIT}'","repository":"'"${REPOSITORY}"'"}],"projects":["'${SENTRY_PROJECT_SLUG}'"]}'
fi
set +x
directoryiterator "${BASE_PATH}/scripts/build"
if [ $? -ne 0 ]; then # If: last exit code is non-zero
exit 1
fi