name: Post-update master jobs

on:
  push:
    branches:
      - master

jobs:
  containers:
    name: Build container images
    runs-on: ubuntu-22.04

    strategy:
      fail-fast: false
      matrix:
        include:
          - dockerfile: Dockerfile
            tag: "latest"
          - dockerfile: Dockerfile.bookworm
            tag: "latest-bookworm"

    steps:
      - uses: actions/checkout@v6

      - name: Set up QEMU
        uses: docker/setup-qemu-action@v3

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v3

      - name: Login to Docker Hub
        uses: docker/login-action@v3
        with:
          username: ${{ secrets.DOCKERHUB_USERNAME }}
          password: ${{ secrets.DOCKERHUB_PASSWORD }}

      - name: Login to GitHub Container Registry
        uses: docker/login-action@v3
        with:
          registry: ghcr.io
          username: ${{ github.repository_owner }}
          password: ${{ secrets.GITHUB_TOKEN }}

      - name: Build and push
        uses: docker/build-push-action@v6
        with:
          context: .
          file: ${{ matrix.dockerfile }}
          platforms: linux/amd64,linux/arm64
          push: true
          tags: |
            schemathesis/schemathesis:${{ matrix.tag }}
            ghcr.io/schemathesis/schemathesis:${{ matrix.tag }}
