diff --git a/.github/workflows/docker-dashboard.yml b/.github/workflows/docker-dashboard.yml index 6a50ab1..59d2cef 100644 --- a/.github/workflows/docker-dashboard.yml +++ b/.github/workflows/docker-dashboard.yml @@ -7,17 +7,32 @@ permissions: on: workflow_dispatch: {} +env: + IMAGE: ghcr.io/tx3-lang/dashboard-frontend + jobs: + # Build each architecture on its own NATIVE runner (no QEMU emulation) and push + # it to GHCR by digest: amd64 on an amd64 runner, arm64 on an arm64 runner. build: - name: Build and push multi-arch image - runs-on: ubuntu-latest + name: Build ${{ matrix.platform }} + runs-on: ${{ matrix.runner }} + strategy: + fail-fast: false + matrix: + include: + - platform: linux/amd64 + runner: ubuntu-latest + - platform: linux/arm64 + runner: ubuntu-24.04-arm steps: + - name: Prepare platform name + run: | + platform=${{ matrix.platform }} + echo "PLATFORM_PAIR=${platform//\//-}" >> "$GITHUB_ENV" + - name: Checkout uses: actions/checkout@v6 - - name: Set up QEMU - uses: docker/setup-qemu-action@v4 - - name: Set up Docker Buildx uses: docker/setup-buildx-action@v4 @@ -28,10 +43,56 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Build and push + - name: Build and push by digest + id: build uses: docker/build-push-action@v7 with: context: ./frontend - platforms: linux/amd64,linux/arm64 - push: true - tags: ghcr.io/tx3-lang/dashboard-frontend:${{ github.sha }} + platforms: ${{ matrix.platform }} + outputs: type=image,name=${{ env.IMAGE }},push-by-digest=true,name-canonical=true,push=true + + - name: Export digest + run: | + mkdir -p "${{ runner.temp }}/digests" + digest="${{ steps.build.outputs.digest }}" + touch "${{ runner.temp }}/digests/${digest#sha256:}" + + - name: Upload digest + uses: actions/upload-artifact@v7 + with: + name: digests-${{ env.PLATFORM_PAIR }} + path: ${{ runner.temp }}/digests/* + if-no-files-found: error + retention-days: 1 + + # Combine the per-arch digests into one multi-arch manifest tagged with the SHA. + merge: + name: Merge multi-arch manifest + runs-on: ubuntu-latest + needs: [build] + steps: + - name: Download digests + uses: actions/download-artifact@v8 + with: + path: ${{ runner.temp }}/digests + pattern: digests-* + merge-multiple: true + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v4 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v4 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Create manifest list and push + working-directory: ${{ runner.temp }}/digests + run: | + docker buildx imagetools create -t "${IMAGE}:${{ github.sha }}" \ + $(printf "${IMAGE}@sha256:%s " *) + + - name: Inspect image + run: docker buildx imagetools inspect "${IMAGE}:${{ github.sha }}"