# Reusable workflow that performs the container build steps for a single platform.
# Used by `pull-docker-dryrun.yml` to run builds in parallel per-platform.
on:
  workflow_call:
    inputs:
      platform:
        description: 'The target platform(s) to build for (e.g. linux/amd64)'
        required: true
        type: string

jobs:
  build-dryrun:
    runs-on: ubuntu-latest
    permissions:
      contents: read
    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
      - uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4.0.0
      - uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
      - name: Build rootful image
        uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0
        with:
          context: .
          platforms: ${{ inputs.platform }}
          push: false
          file: Dockerfile
          cache-from: type=registry,ref=ghcr.io/go-gitea/gitea:buildcache-rootful
      - name: Build rootless image
        uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0
        with:
          context: .
          platforms: ${{ inputs.platform }}
          push: false
          file: Dockerfile.rootless
          cache-from: type=registry,ref=ghcr.io/go-gitea/gitea:buildcache-rootless
