Skip to content

Commit

Permalink
Merge pull request #10 from Sage/region-variable
Browse files Browse the repository at this point in the history
Region agnostic ECR pushing
  • Loading branch information
noodl authored Sep 12, 2024
2 parents b1a6e3f + 62f87ad commit 1ba3f36
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion hooks/post-command
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -euo pipefail

ACTION="$BUILDKITE_PLUGIN_SBC_SHARED_ACTION"

if [[ $ACTION == "push_image" ]];then
if [[ $ACTION == "push_image" ]]; then
echo "--- :floppy_disk: Push $ENVIRONMENT image for $APP"

# Push the docker image
Expand Down
4 changes: 2 additions & 2 deletions hooks/pre-command
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ if [[ -z $GEM_HOST ]]; then
unset GEM_HOST
fi

# Only export the AWS_REGION if it was specified to be overriden.
# Only export the REGION if it was specified to be overriden.
if [[ -n $BUILDKITE_PLUGIN_SBC_SHARED_REGION ]]; then
export AWS_REGION="${BUILDKITE_PLUGIN_SBC_SHARED_REGION}"
export REGION="${BUILDKITE_PLUGIN_SBC_SHARED_REGION}"
fi

# If the target image needs to have a custom tag other than the GH tag/branch
Expand Down
8 changes: 4 additions & 4 deletions lib/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ setup() {
export BUILDKIT_PROGRESS=plain
fi

export BK_ECR=268539851198.dkr.ecr.eu-west-1.amazonaws.com/sageone/buildkite
export BK_CACHE=268539851198.dkr.ecr.eu-west-1.amazonaws.com/sageone/cache
export BK_ECR=268539851198.dkr.ecr.$AWS_REGION.amazonaws.com/sageone/buildkite
export BK_CACHE=268539851198.dkr.ecr.$AWS_REGION.amazonaws.com/sageone/cache

# Needed for --cache-from and --cache-to
docker buildx create --use --bootstrap
Expand Down Expand Up @@ -122,7 +122,7 @@ push_image () {
switches "$@"
validate_switches account_id app tag multiarch
varx BUILDKITE_BUILD_NUMBER
varx AWS_REGION
varx REGION
varx BK_BRANCH

# If the override ENV option was specified in the pipeline, use that tag value.
Expand All @@ -137,7 +137,7 @@ push_image () {
X86_64_TAG_SUFFIX=-x86_64
fi

TARGET_ECR=$account_id.dkr.ecr.$AWS_REGION.amazonaws.com/$REPO:$target_tag
TARGET_ECR=$account_id.dkr.ecr.$REGION.amazonaws.com/$REPO:$target_tag

SOURCE_IMAGE_X86_64=$BK_ECR:$app-$tag-build-$BUILDKITE_BUILD_NUMBER
TARGET_IMAGE_X86_64=$TARGET_ECR$X86_64_TAG_SUFFIX
Expand Down

0 comments on commit 1ba3f36

Please sign in to comment.