-
Notifications
You must be signed in to change notification settings - Fork 0
/
buildspec.yml
67 lines (60 loc) · 2.5 KB
/
buildspec.yml
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
version: 0.2
env:
shell: bash
parameter-store: {}
phases:
pre_build:
on-failure: ABORT
commands:
- echo pre_build started on `date`
- aws --version
- yum install -y jq curl unzip
- echo "ENV -> $ENV"
- echo "AWS_DEFAULT_REGION -> $AWS_DEFAULT_REGION"
- echo "CODEBUILD_SOURCE_REPO_URL -> $CODEBUILD_SOURCE_REPO_URL"
- echo "CODEBUILD_BUILD_IMAGE -> $CODEBUILD_BUILD_IMAGE"
- echo "CODEBUILD_BUILD_NUMBER -> $CODEBUILD_BUILD_NUMBER"
- echo "CODEBUILD_RESOLVED_SOURCE_VERSION -> $CODEBUILD_RESOLVED_SOURCE_VERSION"
- echo "CODEBUILD_BUILD_ID -> $CODEBUILD_BUILD_ID"
- echo "CODEBUILD_BUILD_ARN -> $CODEBUILD_BUILD_ARN"
- AWS_ACCOUNT_ID=$(echo $CODEBUILD_BUILD_ARN | cut -d':' -f5)
- echo $AWS_ACCOUNT_ID
- REPOSITORY_NAME=$(echo $CODEBUILD_BUILD_ID | cut -d':' -f1)
- echo $REPOSITORY_NAME
- BUILD_ID=$(echo $CODEBUILD_BUILD_ID | cut -d':' -f2)
- echo $BUILD_ID
- REPOSITORY_URI=$AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$REPOSITORY_NAME
- echo $REPOSITORY_URI
- IMAGE_VERSION=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7)
- echo $IMAGE_VERSION
- BUILD_URL=$(echo "https://$AWS_DEFAULT_REGION.console.aws.amazon.com/codesuite/codebuild/$AWS_ACCOUNT_ID/projects/$REPOSITORY_NAME/build/$REPOSITORY_NAME%3A$BUILD_ID/?region=$AWS_DEFAULT_REGION")
- echo $BUILD_URL
build:
on-failure: ABORT
commands:
- echo build started on `date`
- cd $CODEBUILD_SRC_DIR/infrastructure/terraform/
- curl --silent -X GET -L https://releases.hashicorp.com/terraform/0.14.3/terraform_0.14.3_linux_amd64.zip --output terraform_0.14.3_linux_amd64.zip
- unzip terraform_0.14.3_linux_amd64.zip && rm -f terraform_0.14.3_linux_amd64.zip
- chmod +x terraform && mv terraform /usr/local/bin/
- aws s3 cp s3://${AWS_BACKEND_BUCKET}/terraform/ecs-cluster/${ENV}.tfvars .
- make init
post_build:
on-failure: ABORT
commands:
- echo post_build started on `date`
- make apply
- |
if [ $CODEBUILD_BUILD_SUCCEEDING = 1 ]; then
content="✔️ Pull request build SUCCEEDED ![View Build]($BUILD_URL)";
else
content="❌ Pull request build FAILED ![View Build]($BUILD_URL)";
fi
- echo "$content"
artifacts:
files: []
secondary-artifacts:
DefinitionArtifact:
files: []
ImageArtifact:
files: []