diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 9a193e4..424694e 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -24,21 +24,27 @@ jobs: id: login-ecr uses: aws-actions/amazon-ecr-login@v2 - - name: Docker build + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Build and push + uses: docker/build-push-action@v4 env: ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} ECR_REPOSITORY: usermap-server IMAGE_TAG: ${{ github.sha }} BRANCH_NAME: ${{ github.ref_name }} - run: | - docker build \ - -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG \ - -t $ECR_REGISTRY/$ECR_REPOSITORY:latest-$BRANCH_NAME \ - -f ./Dockerfile \ - . - - docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG - docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest-$BRANCH_NAME + with: + context: . + push: true + tags: | + ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }} + ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:latest-${{ env.BRANCH_NAME }}-amd64 + cache-from: | + type=registry,ref=${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:cache-${{ env.BRANCH_NAME }} + cache-to: | + type=registry,ref=${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:cache-${{ env.BRANCH_NAME }},mode=max deploy: runs-on: ubicloud