This repository has been archived by the owner on Jul 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.sh
56 lines (46 loc) · 1.55 KB
/
common.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
#
# Common function and variables
#
# path to the current workspace
GITHUB_WORKSPACE="${GITHUB_WORKSPACE:-.}"
# name of the organization and repository, joined by slash
GITHUB_REPOSITORY="${GITHUB_REPOSITORY:-}"
# namespace name for the container registry
REGISTRY_NAMESPACE="${REGISTRY_NAMESPACE:-registry}"
# namespace name for Tekton Pipeline controller
readonly TEKTON_NAMESPACE="tekton-pipelines"
# namespace name for Shipwright Build controller
readonly SHIPWRIGHT_NAMESPACE="shipwright-build"
# timeout employed during rollout status and deployments in general
DEPLOYMENT_TIMEOUT="${DEPLOYMENT_TIMEOUT:-3m}"
# print error message and exit on error.
function fail () {
echo "ERROR: ${*}" >&2
exit 1
}
# uses kubectl to check the deployment status on namespace and name informed.
function rollout_status () {
local namespace="${1}"
local deployment="${2}"
if ! kubectl --namespace="${namespace}" --timeout=${DEPLOYMENT_TIMEOUT} \
rollout status deployment "${deployment}" ; then
fail "'${namespace}/${deployment}' is not deployed as expected!"
fi
}
# inspect the path after the informed executable name.
function probe_bin_on_path() {
local name="${1}"
if ! type -a ${name} >/dev/null 2>&1; then
fail "Can't find '${name}' on \$PATH"
fi
}
# compares the context information shared via the environment to determine if the current repository
# is the name informed.
function is_current_repo () {
local name="${1}"
# when the current repository name matches the informed name
if [ "${GITHUB_REPOSITORY#*/}" == "${name}" ] ; then
return 0
fi
return 1
}