-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·45 lines (34 loc) · 1.06 KB
/
build.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
#!/bin/sh
set -e
BUILD_TYPE=${BUILD_TYPE:-'commit'}
ECR_PATH=093525834944.dkr.ecr.us-east-1.amazonaws.com/hatch-insp/knowledge-base
[email protected]:hatch-is/knowledge-base.git
if [ $BUILD_TYPE = 'commit' ]
then
if [ -z "$REPOSITORY_TAG" ] || [ -z "$GIT_COMMIT" ]
then
echo "[ERROR] Specify REPOSITORY_TAG and GIT_COMMIT. Example: BUILD_TYPE='commit' REPOSITORY_TAG='test' GIT_COMMIT='git_commit_hash'./build.sh"
exit 1
fi
else
if [ ! $BUILD_TYPE = 'release' ]
then
echo "[ERROR] BUILD_TYPE should be 'release' or 'commit'"
exit 1
fi
if [ -z "$REPOSITORY_TAG" ]
then
echo "[ERROR] Specify REPOSITORY_TAG Example: BUILD_TYPE='release' REPOSITORY_TAG='v0.0.1' ./build.sh"
exit 1
fi
GIT_COMMIT=$REPOSITORY_TAG;
fi
eval $(aws ecr get-login --region us-east-1)
rm -rf ./_build/.cache/
git clone $GIT ./_build/.cache/knowledge-base
cd ./_build/.cache/knowledge-base
git tag
git checkout $GIT_COMMIT
cd ../
docker build -t $ECR_PATH:$REPOSITORY_TAG ../
docker push $ECR_PATH:$REPOSITORY_TAG