diff --git a/.github/workflows/build-push-docker.yml b/.github/workflows/build-push-docker.yml index 716d5745..287cc6a6 100644 --- a/.github/workflows/build-push-docker.yml +++ b/.github/workflows/build-push-docker.yml @@ -7,6 +7,9 @@ on: tags: - "*" +env: + PLATFORMS: 'linux/amd64,linux/arm64' + concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true @@ -42,39 +45,12 @@ jobs: fi build-push-image: - name: Build and Push Docker Image for ${{ matrix.arch }} - runs-on: [matterlabs-ci-runner-high-performance] + name: Build and Push Docker Image + runs-on: matterlabs-ci-runner-high-performance needs: set-tags - strategy: - matrix: - include: - - platform: linux/amd64 - arch: amd64 - - platform: linux/arm64 - arch: arm64 steps: - uses: actions/checkout@v4 - - name: Set Base Docker Tag - run: echo "BASE_TAG=${{ needs.set-tags.outputs.base_tag }}" >> $GITHUB_ENV - - - name: Set Repository Owner - run: echo "REPO_OWNER=${{ github.repository_owner }}" >> $GITHUB_ENV - - - name: Set Full Docker Tags - id: full_tags - run: | - base_tag="${{ env.BASE_TAG }}" - arch="${{ matrix.arch }}" - repo_owner="${{ env.REPO_OWNER }}" - if [[ "$base_tag" == "none" ]]; then - echo "tags=none" >> $GITHUB_OUTPUT - exit 0 - fi - echo "ghcr.io/${repo_owner}/anvil-zksync:${base_tag}-${arch}" >> tags.txt - echo "us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/anvil-zksync:${base_tag}-${arch}" >> tags.txt - echo "tags=$(cat tags.txt | tr '\n' ',')" >> $GITHUB_OUTPUT - - name: Login to GAR run: | gcloud auth configure-docker us-docker.pkg.dev -q @@ -95,55 +71,14 @@ jobs: with: context: . push: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/db/multi-platform-docker' || startsWith(github.ref, 'refs/tags/')) }} - platforms: ${{ matrix.platform }} + platforms: ${{ env.PLATFORMS }} cache-from: type=gha cache-to: type=gha,mode=max tags: | - ghcr.io/${{ github.repository_owner }}/anvil-zksync:${{ env.BASE_TAG }}-${{ matrix.arch }} - us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/anvil-zksync:${{ env.BASE_TAG }}-${{ matrix.arch }} + ghcr.io/${{ github.repository_owner }}/anvil-zksync:${{ needs.set-tags.outputs.base_tag }} + us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/anvil-zksync:${{ needs.set-tags.outputs.base_tag }} - name: Print image digest to summary run: | - echo "Image tags: ghcr.io/${{ github.repository_owner }}/anvil-zksync:${{ env.BASE_TAG }}-${{ matrix.arch }}" >> $GITHUB_STEP_SUMMARY - echo "Image tags: us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/anvil-zksync:${{ env.BASE_TAG }}-${{ matrix.arch }}" >> $GITHUB_STEP_SUMMARY - - create-latest-tag: - name: Create and Push Docker Manifest with "latest" Tag - runs-on: [matterlabs-ci-runner] - needs: - - build-push-image - - set-tags - if: needs.set-tags.outputs.base_tag != 'none' - steps: - - name: Login to GAR - run: | - gcloud auth configure-docker us-docker.pkg.dev -q - - - name: Login to GHCR - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Set Repository Owner - run: echo "REPO_OWNER=${{ github.repository_owner }}" >> $GITHUB_ENV - - - name: Set Up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Create and Push Docker Manifest - run: | - docker buildx imagetools create \ - ghcr.io/${{ env.REPO_OWNER }}/anvil-zksync:${{ needs.set-tags.outputs.base_tag }}-amd64 \ - ghcr.io/${{ env.REPO_OWNER }}/anvil-zksync:${{ needs.set-tags.outputs.base_tag }}-arm64 \ - --tag ghcr.io/${{ env.REPO_OWNER }}/anvil-zksync:latest - - docker buildx imagetools create \ - us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/anvil-zksync:${{ needs.set-tags.outputs.base_tag }}-amd64 \ - us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/anvil-zksync:${{ needs.set-tags.outputs.base_tag }}-arm64 \ - --tag us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/anvil-zksync:latest - - - name: Print Manifest Tags to Summary - run: | - echo "Manifest tags: latest" >> $GITHUB_STEP_SUMMARY \ No newline at end of file + echo "Image tags: ghcr.io/${{ github.repository_owner }}/anvil-zksync:${{ needs.set-tags.outputs.base_tag }}" >> $GITHUB_STEP_SUMMARY + echo "Image tags: us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/anvil-zksync:${{ needs.set-tags.outputs.base_tag }}" >> $GITHUB_STEP_SUMMARY \ No newline at end of file