Skip to content

Commit

Permalink
Fix caching args
Browse files Browse the repository at this point in the history
  • Loading branch information
Timothy-Gonzalez committed Oct 27, 2024
1 parent ad614ad commit a9cb6ca
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -82,7 +77,7 @@ jobs:
with:
task-definition: task-definition.json
container-name: ${{ env.CONTAINER_NAME }}
image: ${{ steps.build-image.outputs.image }}
image: ${{ steps.build-image.outputs.imageid }}

- name: Deploy Amazon ECS task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@df9643053eda01f169e64a0e60233aacca83799a
Expand Down

0 comments on commit a9cb6ca

Please sign in to comment.