name: docker-dryrun

on:
  pull_request:

concurrency:
  group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
  cancel-in-progress: true

permissions:
  contents: read

jobs:
  files-changed:
    uses: ./.github/workflows/files-changed.yml

  # QEMU-based build is slow (40-50 minutes), so run arm64 and riscv64 when dockerfile changes.
  # Run amd64 when any docker-related files change, which is fast (4 minutes).
  container-amd64:
    if: needs.files-changed.outputs.docker == 'true'
    needs: [files-changed]
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
      - uses: ./.github/actions/docker-dryrun
        with:
          platform: linux/amd64

  container-arm64:
    if: needs.files-changed.outputs.dockerfile == 'true'
    needs: [files-changed]
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
      - uses: ./.github/actions/docker-dryrun
        with:
          platform: linux/arm64

  container-riscv64:
    if: needs.files-changed.outputs.dockerfile == 'true'
    needs: [files-changed]
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
      - uses: ./.github/actions/docker-dryrun
        with:
          platform: linux/riscv64
