From 515ec89ed4dc793e563638a3e1cb432bf063a1f2 Mon Sep 17 00:00:00 2001 From: Alexander Bayandin Date: Tue, 11 Mar 2025 20:54:48 +0000 Subject: [PATCH] ci/build-images: fix push to ECR (#1315) Push to ECR started to fail after https://github.com/neondatabase/autoscaling/pull/1312 changes: ``` Copy neondatabase/neonvm-controller:testrelease-20250311.1c7bb48.13791913752 to dev ECR ERROR: pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed ``` It tries to push images to `/neondatabase/` instead of `/` --- .github/workflows/build-images.yaml | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-images.yaml b/.github/workflows/build-images.yaml index 4eba87702..6a8d9292d 100644 --- a/.github/workflows/build-images.yaml +++ b/.github/workflows/build-images.yaml @@ -401,6 +401,8 @@ jobs: - name: Copy all merged images to ECR if: ${{ format('{0}', inputs.upload-to-ecr) == 'true' }} + env: + TAG: ${{ inputs.tag }} run: | # note: excludes neonvm-daemon because we only need it during CI, to build compute images. images=("${IMG_CONTROLLER}" \ @@ -411,10 +413,16 @@ jobs: "${IMG_CLUSTER_AUTOSCALER}") for image in "${images[@]}"; do - echo Copy ${image}:${{ inputs.tag }} to dev ECR - docker buildx imagetools create -t ${{ env.ECR_DEV }}/${image}:${{ inputs.tag }} \ - neondatabase/${image}:${{ inputs.tag }} - echo Copy ${image}:${{ inputs.tag }} to prod ECR - docker buildx imagetools create -t ${{ env.ECR_PROD }}/${image}:${{ inputs.tag }} \ - neondatabase/${image}:${{ inputs.tag }} + # Remove "neondatabase/" prefix from image name + image_without_prefix=${image#neondatabase/} + + image_from=${image}:${TAG} + image_ecr_dev="${ECR_DEV}/${image_without_prefix}:${TAG}" + image_ecr_prod="${ECR_PROD}/${image_without_prefix}:${TAG}" + + echo "Copy ${image_from} to ${image_ecr_dev} (dev), and ${image_ecr_prod} (prod)" + + docker buildx imagetools create -t ${image_ecr_dev} \ + -t ${image_ecr_prod} \ + ${image_from} done