This repository was archived by the owner on May 14, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathdeploy.sh
More file actions
177 lines (154 loc) · 3.43 KB
/
deploy.sh
File metadata and controls
177 lines (154 loc) · 3.43 KB
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
#!/bin/bash
## Executes all build instructions
usage="$(basename "$0") [-s] [-b] [-h] [-i] -- deploy script.
where:
-h show the help text
-b Build number. The number of the build. REQUIRED.
-d Debug mode. Prompts before proceeding to script.
-u Owner user.
-g Owner group.
-e Environment
-i Build id (ex: build-24)
To run this script, you must be in the folder that contains the deploy destination (current), the permanent assets folder (link) and the releases (releases) folder. These folders will be attempted to be created if they do not exist."
DEBUG=0
while [[ $# -gt 1 ]]
do
key="$1"
case $key in
-b|--build)
BUILD=$2
shift
;;
-m|--magentoVersion)
MAGENTO_VERSION=$2
shift
;;
-h|--httpPath)
HTTP_PATH=$2
shift
;;
-i|--buildID)
BUILD_ID=$2
shift
;;
-e|--environment)
ENVIRONMENT=$2
shift
;;
-u|--user)
USER=$2
shift
;;
-g|--group)
GROUP=$2
shift
;;
--php)
PHP_EXEC=$2
shift
;;
-d|--deployUser)
DEPLOY_USER=$2
shift
;;
-g|--debug)
DEBUG=$2
shift
;;
-r|--rollbar)
ROLLBAR=$2
shift
;;
-c|--commit)
COMMIT=$2
shift
;;
--sentryOrg)
SENTRY_ORG="$2"
shift
;;
--sentryProjectSlug)
SENTRY_PROJECT_SLUG="$2"
shift
;;
--sentryToken)
SENTRY_TOKEN="$2"
shift
;;
--repository)
REPOSITORY=$2
shift
;;
--pipelineID)
PIPELINE_ID=$2
shift
;;
-h|--help)
echo "$usage"
exit
;;
*)
;;
esac
shift
done
if [ -z ${BUILD+x} ]; then
echo "You must specify the build number (-b)."
exit 125
fi
if [ -z ${BUILD_ID+x} ]; then
BUILD_ID="build-${BUILD}"
fi
if [ -z ${USER+x} ]; then
USER="apache"
fi
if [ -z ${GROUP+x} ]; then
GROUP="apache"
fi
if [ -z ${DEPLOY_USER+x} ]; then
DEPLOY_USER=${USER}
fi
if [ -z ${DEBUG+x} ]; then
DEBUG=0
fi
if [ -z ${USE_SUDO+x} ]; then
USE_SUDO=0
fi
if [ -z ${MAGENTO_VERSION+x} ]; then
MAGENTO_VERSION="2.2"
fi
export DEBUG=${DEBUG}
export BUILD=${BUILD}
export ENVIRONMENT=${ENVIRONMENT}
export BUILD_ID=${BUILD_ID}
export USER=${USER}
export GROUP=${GROUP}
export DEPLOY_USER=${DEPLOY_USER}
export MAGENTO_VERSION=${MAGENTO_VERSION}
export HTTP_PATH=${HTTP_PATH}
export PHP_EXEC=${PHP_EXEC}
printf "Debug Mode: ${DEBUG}"
source "releases/${BUILD_ID}/scripts/utilities/include.sh"
source "releases/${BUILD_ID}/scripts/utilities/php.sh"
if [ ! -z "$ROLLBAR" ]; then
curl --request POST \
--url https://api.rollbar.com/api/1/deploy/ \
--header 'content-type: application/json' \
--data '{"access_token":"'${ROLLBAR}'","environment":"'${ENVIRONMENT}'","revision":"'${COMMIT}'","status":"started"}'
fi
directoryiterator "releases/${BUILD_ID}/scripts/deploy"
if [ ! -z "$ROLLBAR" ]; then
curl --request POST \
--url https://api.rollbar.com/api/1/deploy/ \
--header 'content-type: application/json' \
--data '{"access_token":"'${ROLLBAR}'","environment":"'${ENVIRONMENT}'","revision":"'${COMMIT}'","status":"succeeded"}'
fi
if [ ! -z "$SENTRY_ORG" ]; then
set -x
curl https://sentry.io/api/0/organizations/${SENTRY_ORG}/releases/${PIPELINE_ID}/deploys/ \
-X POST \
-H 'Authorization: Bearer '${SENTRY_TOKEN} \
-H 'Content-Type: application/json' \
-d '{"environment":"'${ENVIRONMENT}'","name":"'${PIPELINE_ID}'"}'
set +x
fi