-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuildspec.yml
More file actions
27 lines (26 loc) · 1.17 KB
/
buildspec.yml
File metadata and controls
27 lines (26 loc) · 1.17 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
# CodeBuild build spec used to push a containerized version of stackmanager to a public ECR repository.
# This is done from CodeBuild rather than a GitHub action because it avoids the need to add AWS credentials to GitHub.
# Builds are triggered by WebHook in GitHub
version: 0.2
phases:
pre_build:
commands:
- echo Logging in to Amazon ECR...
- aws ecr-public get-login-password --region $AWS_DEFAULT_REGION | docker login --username AWS --password-stdin public.ecr.aws
build:
commands:
- VERSION=$(git describe --tags)
- echo "Version $VERSION"
- docker build --build-arg version=$VERSION -t $IMAGE_REPO_NAME:$VERSION .
- MINOR=${VERSION%.*}
- MAJOR=${MINOR%.*}
- docker tag $IMAGE_REPO_NAME:$VERSION $IMAGE_REPO_NAME:$MINOR
- docker tag $IMAGE_REPO_NAME:$VERSION $IMAGE_REPO_NAME:$MAJOR
- docker tag $IMAGE_REPO_NAME:$VERSION $IMAGE_REPO_NAME:latest
post_build:
commands:
- echo Pushing the Docker image...
- docker push $IMAGE_REPO_NAME:$VERSION
- docker push $IMAGE_REPO_NAME:$MINOR
- docker push $IMAGE_REPO_NAME:$MAJOR
- docker push $IMAGE_REPO_NAME:latest