-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·47 lines (37 loc) · 1.22 KB
/
deploy.sh
File metadata and controls
executable file
·47 lines (37 loc) · 1.22 KB
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
OUTPUT=$(node -e "process.stdout.write(require('./apps/wiki/next.config.js').output ?? '')")
if [ "$OUTPUT" != "" ]; then
echo "next.config.js 에서 \`output\` 속성 제거"
exit 1
fi
export NS=deptno
TAG=latest
GIT_COMMIT=$(git rev-parse --short @)
CHANGE_CAUSE="$(date '+%Y%m%d-%H:%M:%S') $(git rev-parse --abbrev-ref @)@$(git show --no-patch --oneline)"
NAME=wiki
APP_MS=meilisearch-updater
YAML=../cluster-amd64/manifest/$NAME.yaml
PERMISSION="$(kubectl auth can-i update deployment -n deptno)"
set -e
echo $PERMISSION
if [[ "no" == $PERMISSION ]]; then
echo "no permission"
exit 1
fi
if [[ "error: You must be logged in to the server (Unauthorized)" == "$PERMISSION" ]]; then
echo "not authorized"
exit 1
fi
echo $YAML
docker build . \
--progress plain \
--platform linux/amd64 \
--build-arg GIT_COMMIT=$GIT_COMMIT \
-t harbor.deptno.dev/deptno/$NAME:$TAG \
-t harbor.deptno.dev/deptno/$NAME:$GIT_COMMIT
docker push harbor.deptno.dev/deptno/$NAME:$TAG
docker push harbor.deptno.dev/deptno/$NAME:$GIT_COMMIT
cat $YAML \
| sed "s|$APP_MS:.*|$APP_MS:$GIT_COMMIT|" \
| sed "s|$NAME:.*|$NAME:$GIT_COMMIT|" \
| kubectl apply -f -
kubectl annotate -n $NS deployment/$NAME kubernetes.io/change-cause="$CHANGE_CAUSE"