-
Notifications
You must be signed in to change notification settings - Fork 2
/
execute_action.sh
executable file
·65 lines (58 loc) · 1.45 KB
/
execute_action.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/bash
BOT_NAME=$1
FOLDER_PATH=$2
IMG=$3
TAG=$4
VERSION=$5 #v4.5.7
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$(pwd)
function kustomize_set_image {
git config --global user.name "${BOT_NAME}"
git config --global user.email "${BOT_NAME}@email.com"
git pull
pushd ${FOLDER_PATH}
kustomize edit set image ${IMG}:${TAG}
popd
git add .
git commit -m "Image updated"
git push
}
function setup_kustomize {
case $(uname -m) in
x86_64)
ARCH=amd64
;;
arm64|aarch64)
ARCH=arm64
;;
ppc64le)
ARCH=ppc64le
;;
s390x)
ARCH=s390x
;;
*)
ARCH=amd64
;;
esac
OPSYS=windows
if [[ "$OSTYPE" == linux* ]]; then
OPSYS=linux
elif [[ "$OSTYPE" == darwin* ]]; then
OPSYS=darwin
fi
curl -sLO "https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2F${VERSION}/kustomize_${VERSION}_${OPSYS}_${ARCH}.tar.gz"
tar xzf ./kustomize_v*_${OPSYS}_${ARCH}.tar.gz
$(pwd)/kustomize
}
if test "$#" -ne 5; then
echo "Invalid number of Arguments, plesase specify the correct number of arguments"
echo "Please refer https://github.com/arunalakmal/kustomize_actions#readme for more information."
exit 1
elif [[ $(pwd)/kustomize ]]; then
echo "kustomize already installed"
kustomize_set_image
else
echo "kustomize not installed"
setup_kustomize
kustomize_set_image
fi