build: enable multi platform build #6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build | ||
| on: | ||
| push: | ||
| tags: ['*'] | ||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 1 | ||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
| - name: Extract tag name | ||
| shell: bash | ||
| run: echo "##[set-output name=tag;]$(echo ${GITHUB_REF#refs/tags/} | sed 's#/#_#g')" | ||
| id: extract_refs | ||
| - name: Cache Docker layers | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: /tmp/.buildx-cache | ||
| key: ${{ runner.os }}-buildx-${{ github.ref }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-buildx- | ||
| - name: Configure AWS Credentials | ||
| uses: aws-actions/configure-aws-credentials@v4 | ||
| with: | ||
| aws-access-key-id: ${{ vars.GH_AWS_ACCESS_KEY_ID }} | ||
| aws-secret-access-key: ${{ secrets.GH_AWS_SECRET_ACCESS_KEY }} | ||
| aws-region: us-east-1 | ||
| - name: Login to Amazon ECR Public | ||
| id: login-ecr-public | ||
| uses: aws-actions/amazon-ecr-login@v2 | ||
| with: | ||
| registry-type: public | ||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
| - name: Build & Push Image | ||
| uses: docker/build-push-action@v6 | ||
| with: | ||
| load: true | ||
| push: true | ||
| platform: | ||
| - linux/amd64 | ||
| - linux/arm64 | ||
| tags: ${{ steps.login-ecr-public.outputs.registry }}/${{ vars.ECS_REGISTRY_ALIAS }}/${{ vars.ECS_REPOSITORY_NAME }}:${{ steps.extract_refs.outputs.tag }} | ||
| cache-from: type=local,src=/tmp/.buildx-cache | ||
| cache-to: type=local,dest=/tmp/.buildx-cache-new | ||
| - | ||
| # Temp fix | ||
| # https://github.com/docker/build-push-action/issues/252 | ||
| # https://github.com/moby/buildkit/issues/1896 | ||
| name: Move cache | ||
| run: | | ||
| rm -rf /tmp/.buildx-cache | ||
| mv /tmp/.buildx-cache-new /tmp/.buildx-cache | ||