Forked from tvalletta/aws-codebuild-cross-account-image-push.yml
Created
September 15, 2017 15:58
-
-
Save addicola/05f1177920d449d703a42bc009612ee4 to your computer and use it in GitHub Desktop.
Revisions
-
tvalletta created this gist
Feb 17, 2017 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ version: 0.1 # REQUIRED ENVIRONMENT VARIABLES # AWS_KEY - AWS Access Key ID # AWS_SEC - AWS Secret Access Key # AWS_REG - AWS Default Region (e.g. us-west-2) # AWS_OUT - AWS Output Format (e.g. json) # AWS_PROF - AWS Profile name (e.g. central-account) # IMAGE_REPO_NAME - Name of the image repo (e.g. my-app) # IMAGE_TAG - Tag for the image (e.g. latest) # AWS_ACCOUNT_ID - Remote AWS account id (e.g. 555555555555) phases: pre_build: commands: - printf "${AWS_KEY}\n${AWS_SEC}\n${AWS_REG}\n${AWS_OUT}\n" | aws configure --profile ${AWS_PROF} - $(aws ecr get-login --profile ${AWS_PROF}) build: commands: - docker build -t $IMAGE_REPO_NAME . - docker tag $IMAGE_REPO_NAME:$IMAGE_TAG $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REG.amazonaws.com/$IMAGE_REPO_NAME:$IMAGE_TAG post_build: commands: - docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REG.amazonaws.com/$IMAGE_REPO_NAME:$IMAGE_TAG