Skip to content

Instantly share code, notes, and snippets.

@shinichi-takayanagi
Created April 3, 2020 01:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shinichi-takayanagi/f0e1bad18ccedb8fdc0da3f64c11676a to your computer and use it in GitHub Desktop.
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
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