name: PR build Spring Boot images for smoke tests

on:
  pull_request:
    paths:
      - 'smoke-tests/images/spring-boot/**'
      - '.github/workflows/pr-smoke-test-spring-boot-images.yml'

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3

      - name: Set up JDK 11 for running Gradle
        uses: actions/setup-java@v2
        with:
          distribution: temurin
          java-version: 11

      - name: Set up gradle cache
        uses: gradle/gradle-build-action@v2
        with:
          cache-read-only: true

      - name: Build Java 8 Docker Image
        run: ./gradlew jibDockerBuild -PtargetJDK=8 -Djib.httpTimeout=120000 -Djib.console=plain
        working-directory: smoke-tests/images/spring-boot

      - name: Build Java 11 Docker Image
        run: ./gradlew jibDockerBuild -PtargetJDK=11 -Djib.httpTimeout=120000 -Djib.console=plain
        working-directory: smoke-tests/images/spring-boot

      - name: Build Java 17 Docker Image
        run: ./gradlew jibDockerBuild -PtargetJDK=17 -Djib.httpTimeout=120000 -Djib.console=plain
        working-directory: smoke-tests/images/spring-boot

      - name: Build Java 18 Docker Image
        run: ./gradlew jibDockerBuild -PtargetJDK=18 -Djib.httpTimeout=120000 -Djib.console=plain
        working-directory: smoke-tests/images/spring-boot
