aws-actions / amazon-ecr-login

Logs into Amazon ECR with the local Docker client.
MIT License
929 stars 176 forks source link

Compatibility with `docker/build-push-action` #486

Open gsuess opened 1 year ago

gsuess commented 1 year ago

Is aws-actions/amazon-ecr-login compatible with docker/build-push-action?

This should be documented in the readme. I am wondering if I can just have this:

- name: AWS Assume Role
  uses: aws-actions/configure-aws-credentials@v2
  with:
    role-to-assume: ${{ vars.AWS_OIDC_ACCESS_ROLE }}
    aws-region: eu-central-1

- name: Log in to the Container registry
  id: ecr-login
  uses: aws-actions/amazon-ecr-login@v1

- name: Docker meta
  id: meta
  uses: docker/metadata-action@v4
  with:
    images: ${{ steps.ecr-login.outputs.registry }}/${{ env.IMAGE_NAME }}

- name: Set up Docker Build
  uses: docker/setup-buildx-action@v2

- name: Build and push
   id: push
   uses: docker/build-push-action@v4
   with:
     push: true
     tags: ${{ steps.meta.outputs.tags }}
     labels: ${{ steps.meta.outputs.labels }}

I will go ahead and test it and report back here, but either I think it should documented or if its not compatible, perhaps it can be made compatible?

It would make transitioning container registry to ECR easier as less changes would be needed for existing workflows.

It would also allow reusability of workflows so that they deploy to multiple registries.

gsuess commented 1 year ago

Okay turns out that the above works fine so the two actions are compatible with each other.

I believe this is a better approach the one currently documented on the Readme.md.