From 19a35aa5269738e722961b6b6497b6aa541201c2 Mon Sep 17 00:00:00 2001 From: Timothy-Gonzalez <105177619+Timothy-Gonzalez@users.noreply.github.com> Date: Sun, 27 Oct 2024 16:31:52 -0500 Subject: [PATCH] Fix caching args --- .github/workflows/release.yml | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d492e3bb..b7b10af1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -49,28 +49,23 @@ jobs: aws-region: ${{ env.AWS_REGION }} - name: Login to Amazon ECR - id: login-ecr + id: login uses: aws-actions/amazon-ecr-login@62f4f872db3836360b72999f4b87f1ff13310f3a - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Build, tag, and push image to Amazon ECR + # Caching through args is from: https://aws.amazon.com/blogs/containers/announcing-remote-cache-support-in-amazon-ecr-for-buildkit-clients/ + - name: Build, tag, and push to ECR id: build-image + uses: docker/build-push-action@v6 env: - ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} - IMAGE_TAG: ${{ github.sha }} - run: | - # Build a docker container and - # push it to ECR so that it can - # be deployed to ECS. - # Caching through args is from: https://aws.amazon.com/blogs/containers/announcing-remote-cache-support-in-amazon-ecr-for-buildkit-clients/ - docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . \ - --cache-to mode=max,image-manifest=true,oci-mediatypes=true,type=registry,ref=$ECR_REGISTRY/$ECR_REPOSITORY \ - --cache-from type=registry,ref=$ECR_REGISTRY/$ECR_REPOSITORY:cache - - docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG - echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT + ECR_URI: ${{ steps.login.outputs.registry }}/${{ env.ECR_REPOSITORY }} + with: + push: true + tags: ${{ env.ECR_URI }}:${{ github.sha }} + cache-from: type=registry,ref=${{ env.ECR_URI }}:cache + cache-to: type=registry,mode=max,image-manifest=true,oci-mediatypes=true,ref=${{ env.ECR_URI }}:cache - name: Download current task definition run: | @@ -82,7 +77,7 @@ jobs: with: task-definition: task-definition.json container-name: ${{ env.CONTAINER_NAME }} - image: ${{ steps.build-image.outputs.image }} + image: ${{ steps.login.outputs.registry }}/${{ env.ECR_REPOSITORY }}:${{ github.sha }} - name: Deploy Amazon ECS task definition uses: aws-actions/amazon-ecs-deploy-task-definition@df9643053eda01f169e64a0e60233aacca83799a