Create Multi Arch Pipelines with Github Actions.

Create Multi Arch Pipelines with Github Actions.

Hello, I would like to share with you a sample Github workflow which builds Multiple Architecture Docker Images and finally push them to DockerHub.

# https://github.com/docker/metadata-action
name: Multi-Arch-Build
on: 
   workflow_dispatch:

jobs:
  buildx:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3
      - name: Set up QEMU
        uses: docker/setup-qemu-action@v2
      - name: Set up Docker Buildx
        id: buildx
        uses: docker/setup-buildx-action@v2
      - name: Inspect builder # Debug only
        run: |
          echo "Name:      ${{ steps.buildx.outputs.name }}"
          echo "Endpoint:  ${{ steps.buildx.outputs.endpoint }}"
          echo "Status:    ${{ steps.buildx.outputs.status }}"
          echo "Flags:     ${{ steps.buildx.outputs.flags }}"
          echo "Platforms: ${{ steps.buildx.outputs.platforms }}"
      - name: Login to Docker Hub
        uses: docker/login-action@v2
        with:
          username: ${{ secrets.DOCKER_USER }}
          password: ${{ secrets.DOCKER_PASS }}
      - name: Docker meta
        id: meta
        uses: docker/metadata-action@v4
        with:
          images: <docherhub-repo>/<actual-name># <specify the image name>
          tags: <sample>-${{ github.run_number }} # Tag
      - name: Build and push
        uses: docker/build-push-action@v3
        with:
          context: ./test/
          platforms: linux/amd64,linux/arm/v7,linux/arm64,linux/arm/v6
          push: ${{ github.event_name != 'pull_request' }}
          tags: ${{ steps.meta.outputs.tags }}
          labels: ${{ steps.meta.outputs.labels }}

Result

Image description

I hope you like the tutorial, if you do give a thumps up! and follow me in Twitter, also you can subscribe to my Newsletter in order to avoid missing any of the upcoming tutorials.

Media Attribution

I would like to thank Clark Tibbs for designing the awesome photo I am using in my posts.

Thank you, Cheers!!!