name: PR build fake backend images for smoke tests

on:
  pull_request:
    paths:
      - "smoke-tests/images/fake-backend/**"
      - ".github/workflows/pr-smoke-test-fake-backend-images.yml"

permissions:
  contents: read

jobs:
  buildLinux:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2

      - name: Free disk space
        run: .github/scripts/gha-free-disk-space.sh

      - name: Set up JDK for running Gradle
        uses: actions/setup-java@9704b39bf258b59bc04b50fa2dd55e9ed76b47a8 # v4.1.0
        with:
          distribution: temurin
          java-version: 17.0.6

      - name: Build Docker image
        uses: gradle/gradle-build-action@29c0906b64b8fc82467890bfb7a0a7ef34bda89e # v3.1.0
        with:
          arguments: ":smoke-tests:images:fake-backend:jibDockerBuild -Djib.httpTimeout=120000 -Djib.console=plain"
          cache-read-only: true
          # gradle enterprise is used for the build cache
          gradle-home-cache-excludes: caches/build-cache-1

  buildWindows:
    runs-on: windows-latest
    defaults:
      run:
        shell: bash
    steps:
      - name: Support long paths
        run: git config --system core.longpaths true

      - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2

      - name: Set up JDK for running Gradle
        uses: actions/setup-java@9704b39bf258b59bc04b50fa2dd55e9ed76b47a8 # v4.1.0
        with:
          distribution: temurin
          java-version: 17.0.6

      - name: Build Docker image
        uses: gradle/gradle-build-action@29c0906b64b8fc82467890bfb7a0a7ef34bda89e # v3.1.0
        with:
          arguments: ":smoke-tests:images:fake-backend:windowsBackendImageBuild"
          cache-read-only: true
