skip to Main Content

I have a github build that pushes images to ECR, but when they get there, they show up as untagged / no way i can see to tell image / platform etc is created. Is this a bug or a mistake my end?

GHA:

name: push
on: [workflow_dispatch]
env:
  ECR_REPOSITORY: gha
jobs:
  build-image:
    name: Build Images
    runs-on: ubuntu-latest
    steps:
    
      - uses: actions/checkout@v3
 
      - name: Configure AWS credentials
        uses: aws-actions/configure-aws-credentials@v2
        with:
          aws-access-key-id: ${{ secrets.AWS_MGMT_ECR_ID }}
          aws-secret-access-key: ${{ secrets.AWS_MGMT_ECR_KEY }}
          aws-region: eu-west-2

      - name: Login to Amazon ECR
        id: login-ecr
        uses: aws-actions/amazon-ecr-login@v1

      - name: Set up QEMU
        uses: docker/setup-qemu-action@v2
        
      - name: Set up docker buildx
        uses: docker/setup-buildx-action@v2
 
      - name: Docker meta
        id: meta
        uses: docker/metadata-action@v4
        with:
          images: |
            ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}
          tags: |
            type=semver,pattern={{version}},value=1.0.0
        env:
          ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
      
      - name: Docker build
        uses: docker/build-push-action@v4
        with:
          push: true
          tags: ${{ steps.meta.outputs.tags }}
          platforms: linux/amd64,linux/arm64

And in ECR i then see:

enter image description here

2

Answers


  1. I didn’t use the metadata action. But here is a sample working with ECR:

        steps:
      - name: Checkout
        uses: actions/checkout@v3
    
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v2
    
      - name: Cache Docker layers
        uses: actions/cache@v2
        with:
          path: /tmp/.buildx-cache
          key: ${{ runner.os }}-buildx-${{ github.sha }}
          restore-keys: |
            ${{ runner.os }}-buildx-
    
      - name: Configure AWS credentials
        uses: aws-actions/configure-aws-credentials@v1-node16
        with:
          role-to-assume: ${{ env.ROLE_TO_ASSUME }}
          role-session-name: github-actions-${{ env.APP_NAME }}
          aws-region: ${{ env.AWS_REGION }}
    
      - name: Login to Amazon ECR
        id: login-ecr
        uses: aws-actions/amazon-ecr-login@v1
    
      - name: Set short sha
        id: sha_short
        run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
    
      - name: Build and push
        uses: docker/build-push-action@v4
        with:
          context: .
          file: ./Dockerfile
          push: true
          tags: ${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_REPOSITORY }}:${{ steps.sha_short.outputs.sha_short }}
          cache-from: type=local,src=/tmp/.buildx-cache
          cache-to: type=local,dest=/tmp/.buildx-cache
          provenance: false
    
    Login or Signup to reply.
  2. Just add provenance: false in docker/build-push-action@v4

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search