Created
April 3, 2020 01:23
-
-
Save shinichi-takayanagi/f0e1bad18ccedb8fdc0da3f64c11676a to your computer and use it in GitHub Desktop.
Docker image build and push to AWS ECR using bitbucket pipelines depending on branch/tag
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
definitions: | |
steps: | |
- step: &build-and-push | |
script: | |
- IMAGE_TAG=$(cat TAG.txt) | |
- echo ${IMAGE_TAG} | |
- IMAGE_NAME = <your-image-name> | |
- docker build -t $IMAGE_NAME . | |
- pipe: atlassian/aws-ecr-push-image:1.1.1 | |
variables: | |
IMAGE_NAME: $IMAGE_NAME | |
TAGS: ${IMAGE_TAG} | |
pipelines: | |
default: | |
- step: | |
script: | |
- echo ${BITBUCKET_BRANCH} > TAG.txt | |
artifacts: | |
- TAG.txt | |
- step: *build-and-push | |
branches: | |
master: | |
- step: | |
script: | |
- echo latest > TAG.txt | |
artifacts: | |
- TAG.txt | |
- step: *build-and-push | |
tags: | |
v*: | |
- step: | |
script: | |
- echo ${BITBUCKET_TAG} > TAG.txt | |
artifacts: | |
- TAG.txt | |
- step: *build-and-push |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment