-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.sh
executable file
·47 lines (39 loc) · 1.48 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
#!/bin/bash
export REPONAME=$1
export REPOADDRESS=$2
export CHART=$3
export PROJECT=$4
export KIND=$5
export APIVERSION=$6
export IMAGENAME=$7
echo "Removing old operator at ${PROJECT}"
rm -rf ${PROJECT}
echo "Removed old operator"
echo "Adding helm repo ${REPONAME} on ${REPOADDRESS}"
helm repo add $REPONAME $REPOADDRESS
echo "Pulling helm chart ${CHART}"
helm pull $CHART
export HELMCHARTARCHIVENAME=`ls $(cut -d'/' -f2 <<< $CHART)*`
echo "Pulled helm chart ${CHART} archive name is ${HELMCHARTARCHIVENAME}"
echo "Building operator in new project ${PROJECT} with Kind ${KIND} on ApiVersion ${APIVERSION}"
operator-sdk new $PROJECT --type=helm --kind=$KIND --api-version=$APIVERSION --helm-chart=$HELMCHARTARCHIVENAME
echo "Build operator"
echo "Changing image-name ${IMAGENAME} in deployment-files"
cd ./$PROJECT
sed -i "s|REPLACE_IMAGE|${IMAGENAME}|g" deploy/operator.yaml
sed -i "s|REPLACE_IMAGE|${IMAGENAME}|g" deploy/operator.yaml
echo "changed to image-name"
echo "removing CR"
mv deploy/crds/*_cr.yaml .
ls
echo "removed CR"
echo "Adding to repository"
git config --global user.email "[email protected]"
git config --global user.name "build-helm-operator-action"
git remote add github "https://$GITHUB_ACTOR:[email protected]/$GITHUB_REPOSITORY.git"
git pull github $GITHUB_REF --ff-only
git add .
git commit -m "Build operator ${PROJECT} for ${APIVERSION}/${KIND} with the operator-sdk with ${CHART}"
git push github HEAD:$GITHUB_REF
echo "ready..."
echo "::set-output name=time::$(date)"