diff --git a/.github/workflows/docker-build-push.yaml b/.github/workflows/docker-build-push.yaml index d31a405..2f1864a 100644 --- a/.github/workflows/docker-build-push.yaml +++ b/.github/workflows/docker-build-push.yaml @@ -1,53 +1,66 @@ -name: Build and Push Docker Image (amd64 & arm64) +name: Build and Push Docker Image (native amd64 & arm64) on: push: - branches: ["main"] + branches: ["main", "workflow"] env: REGISTRY: ghcr.io - IMAGE_NAME: ${{ github.repository_owner }}/ros-core + IMAGE_NAME: high-flyers/ros-core jobs: - build-and-push: - runs-on: ubuntu-latest + build: + strategy: + matrix: + include: + - arch: amd64 + runner: ubuntu-latest + platform: linux/amd64 + - arch: arm64 + runner: ubuntu-24.04-arm + platform: linux/arm64 + runs-on: ${{ matrix.runner }} permissions: contents: read packages: write - steps: - name: Checkout repository uses: actions/checkout@v4 - - name: Log in to the Container registry + - name: Log in to GHCR uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - with: - platforms: arm64 - - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@v5 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - tags: | - type=raw,value=latest - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Build and push (amd64 & arm64) + - name: Build and push image (${{ matrix.platform }}) uses: docker/build-push-action@v5 with: context: . file: ./images/ros-core.Dockerfile - platforms: linux/amd64,linux/arm64 push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} + platforms: ${{ matrix.platform }} + tags: | + ghcr.io/high-flyers/ros-core:latest + ghcr.io/high-flyers/ros-core:${{ matrix.arch }} + + manifest: + runs-on: ubuntu-latest + needs: build + permissions: + packages: write + steps: + - name: Log in to GHCR + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Create and push multi-arch manifest + run: | + docker buildx imagetools create \ + -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest \ + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:amd64 \ + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:arm64