This repository has been archived by the owner on Dec 13, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
ecs-conex.sh
executable file
·67 lines (48 loc) · 1.58 KB
/
ecs-conex.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env bash
set -eu
set -o pipefail
regions=(us-east-1 us-west-2 eu-west-1)
bucket_regions=($ImageBucketRegions)
tmpdir="$(mktemp -d /tmp/XXXXXX)"
source utils.sh
function main() {
echo "checking docker version compatibility"
version-check
echo "checking docker configuration"
docker version > /dev/null
echo "checking environment configuration"
MessageId=${MessageId}
Message=${Message}
AccountId=${AccountId}
GithubAccessToken=${GithubAccessToken}
StackRegion=${StackRegion}
ApproximateReceiveCount=${ApproximateReceiveCount}
echo "checking job receive count"
check_receives
echo "parsing received message"
parse_message
echo "processing commit ${after} by ${user} to ${ref} of ${owner}/${repo}"
status="pending"
echo "sending ${status} status to github"
github_status "${status}" "ecs-conex is building an image"
[ "${deleted}" == "true" ] && exit 0
git clone -q https://${GithubAccessToken}@github.com/${owner}/${repo} ${tmpdir}
cd ${tmpdir} && git checkout -q $after || exit 3
echo "looking for dockerfile"
check_dockerfile ./Dockerfile
echo "gather local credentials and setup --build-arg"
credentials ./Dockerfile
echo "logging into ECR repositories in ${regions[*]}"
ecr_logins "${regions[@]}"
echo "building new image"
docker build --no-cache ${args} --tag ${repo}:${after} ${tmpdir}
echo "writing images to ECR"
docker_push
echo "conditionally saving image tarball"
docker_save
echo "conditionally writing image tarballs to S3"
bucket_push
echo "completed successfully"
}
trap "cleanup" EXIT
main 2>&1