-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.sh
executable file
·50 lines (41 loc) · 2.21 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
#!/bin/bash
if [[ "$GITOPS_BRANCH" == "develop" ]]; then
printf "\033[0;36m================================================================================================================> Condition 1: Develop environment \033[0m\n"
printf "\033[0;32m============> Cloning $5 - Branch: develop \033[0m\n"
git clone https://$4@$6 -b develop
cd $5
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
echo "Repo $5 cloned!!!"
printf "\033[0;32m============> Control plane dev branch Kustomize step - develop Overlay \033[0m\n"
cd k8s/$1/overlays/develop
kustomize edit set image IMAGE=$2/$1:$RELEASE_VERSION
echo "Done!!"
printf "\033[0;32m============> Git push: Branch develop \033[0m\n"
cd ../..
git commit -am "$3 has Built a new version: $RELEASE_VERSION"
git push origin develop
elif [[ "$GITOPS_BRANCH" == "main" ]]; then
printf "\033[0;36m================================================================================================================> Condition 3: New release (HML and PRD environment) \033[0m\n"
printf "\033[0;32m============> Cloning $5 - Branch: $GITOPS_BRANCH \033[0m\n"
git clone https://$4@$6 -b develop
cd $5
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
echo "Repo $5 cloned!!!"
printf "\033[0;32m============> Develop branch Kustomize step - develop Overlay \033[0m\n"
cd k8s/$1/overlays/develop
kustomize edit set image IMAGE=$2/$1:$RELEASE_VERSION
echo "Done!!"
printf "\033[0;32m============> Develop branch Kustomize step - PRD Overlay \033[0m\n"
cd ../production
kustomize edit set image IMAGE=$2/$1:$RELEASE_VERSION
echo "Done!!"
printf "\033[0;32m============> Git commit and push: Branch develop \033[0m\n"
cd ../..
git commit -am "$3 has Built a new version: $RELEASE_VERSION"
git push origin develop
printf "\033[0;32m============> Open PR: develop -> main \033[0m\n"
export GITHUB_TOKEN=$4
gh pr create --head develop --base main -t "GitHub Actions: Automatic PR opened by $3 - $RELEASE_VERSION" --body "GitHub Actions: Automatic PR opened by $3 - $RELEASE_VERSION"
fi