forked from okteto/pipeline
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentrypoint.sh
executable file
·65 lines (51 loc) · 1.27 KB
/
entrypoint.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
#!/bin/sh
set -ex
name=$1
namespace=$2
timeout=$3
skip_if_exists=$4
variables=$5
filename=$6
if [ -z $name ]; then
echo "name parameter is mandatory"
exit 1
fi
if [ ! -z "$OKTETO_CA_CERT" ]; then
echo "Custom certificate is provided"
echo "$OKTETO_CA_CERT" > /usr/local/share/ca-certificates/okteto_ca_cert
update-ca-certificates
fi
if [ -z $GITHUB_REF ]; then
echo "fail to detect branch name"
exit 1
fi
repository=$GITHUB_REPOSITORY
if [ "${GITHUB_EVENT_NAME}" = "pull_request" ]; then
branch=${GITHUB_HEAD_REF}
else
branch=$(echo ${GITHUB_REF#refs/heads/})
fi
params=""
if [ ! -z $namespace ]; then
params="--namespace=$namespace"
fi
if [ ! -z $timeout ]; then
params="${params} --timeout=$timeout"
fi
if [ "$skip_if_exists" == "true" ]; then
params="${params} --skip-if-exists"
fi
variable_params=""
if [ ! -z "${variables}" ]; then
for ARG in $(echo "${variables}" | tr ',' '\n'); do
variable_params="${variable_params} --var ${ARG}"
done
params="${params} $variable_params"
fi
if [ ! -z "$filename" ]; then
params="${params} -f "${filename}""
fi
export OKTETO_DISABLE_SPINNER=1
output="okteto pipeline deploy --name "${name}" --branch="${branch}" --repository="${GITHUB_SERVER_URL}/${repository}" ${params} --wait"
echo running: $output
eval $output