# Copyright 2022 Google LLC
#
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file or at
# https://developers.google.com/open-source/licenses/bsd

# A workflow to build the official docker image.
name: Official Docker image

on:
  # Runs when called from another workflow.
  workflow_call:
    inputs:
      ref:
        required: true
        type: string

  # Runs when triggered manually by a maintainer.
  workflow_dispatch:
    inputs:
      ref:
        description: The ref to build from.
        required: true
        type: string

# By default, run all commands in a bash shell.  On Windows, the default would
# otherwise be powershell.
defaults:
  run:
    shell: bash

jobs:
  official_docker_image:
    strategy:
      fail-fast: false
      matrix:
        include:
          - docker_platform: linux/amd64
            runs_on: ubuntu-latest

          - docker_platform: linux/arm64
            runs_on: ubuntu-24.04-arm

    name: Build ${{ matrix.docker_platform }}
    runs-on: ${{ matrix.runs_on }}

    steps:
      - name: Checkout code
        uses: actions/checkout@v4
        with:
          ref: ${{ inputs.ref }}
          submodules: recursive
          persist-credentials: false

      - name: Build
        shell: bash
        run: docker buildx build --platform ${{ matrix.docker_platform }} .
