-
-
Notifications
You must be signed in to change notification settings - Fork 986
Expand file tree
/
Copy pathpush.sh
More file actions
executable file
·44 lines (39 loc) · 1.75 KB
/
push.sh
File metadata and controls
executable file
·44 lines (39 loc) · 1.75 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
#!/bin/bash
set -e
export COMMIT_ID=$(git rev-parse HEAD)
export TRAVIS_BRANCH=$(git rev-parse --abbrev-ref HEAD)
export AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
build_and_push() {
aws configure set default.region us-east-1
eval $(aws ecr get-login --no-include-email)
echo "Pulling ssl certificates and nginx configuration..."
# Pull ssl files related to eval.ai
aws s3 cp s3://cloudcv-secrets/eval.ai/ssl/ ./ssl/ --recursive
# Need ssl files related to *.cloudcv.org since we want to provide backward compatibility
aws s3 cp s3://cloudcv-secrets/evalai/${TRAVIS_BRANCH}/ssl/ ./ssl/ --recursive
echo "Pulled ssl certificates and nginx configuration successfully"
docker-compose -f docker-compose-$1.yml build \
--build-arg COMMIT_ID=${COMMIT_ID} \
--build-arg TRAVIS_BRANCH=${TRAVIS_BRANCH} \
--build-arg AWS_ACCOUNT_ID=${AWS_ACCOUNT_ID} --compress
docker-compose -f docker-compose-$1.yml push
# Get already built docker images
images=$(cat docker-compose-$1.yml | grep 'image: ${AWS_ACCOUNT_ID' | cut -d':' -f 2 | tr -d '"')
# Tag & push images with latest tag
for image in $images
do
eval image=${image}
docker tag ${image}:${COMMIT_ID} ${image}:latest
docker push ${image}:latest
done
}
if [ "${TRAVIS_PULL_REQUEST}" != "false" ]; then
echo "Skipping deploy to staging or production server; The request or commit is not on staging or production branch"
exit 0
elif [ "${TRAVIS_BRANCH}" == "staging" -o "${TRAVIS_BRANCH}" == "production" ]; then
build_and_push $TRAVIS_BRANCH
exit 0
else
echo "Skipping deploy!"
exit 0
fi