name: Record screenshots

on:
  workflow_dispatch:

# Enrich gradle.properties for CI/CD
env:
  GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx4g -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError" -Dkotlin.daemon.jvm.options="-Xmx3584m" -Dkotlin.incremental=false -XX:+UseParallelGC

jobs:
  record:
    name: Record screenshots on branch ${{ github.ref_name }}
    runs-on: ubuntu-latest

    steps:
      - name: ⏬ Checkout with LFS
        uses: nschloe/action-cached-lfs-checkout@v1.2.2
        with:
          persist-credentials: false
      - name: ☕️ Use JDK 17
        uses: actions/setup-java@v3
        with:
          distribution: 'temurin' # See 'Supported distributions' for available options
          java-version: '17'
      # Add gradle cache, this should speed up the process
      - name: Configure gradle
        uses: gradle/gradle-build-action@v2.9.0
        with:
          cache-read-only: ${{ github.ref != 'refs/heads/develop' }}
      - name: Record screenshots
        run: "./.github/workflows/scripts/recordScreenshots.sh"
        env:
          GITHUB_TOKEN: ${{ secrets.DANGER_GITHUB_API_TOKEN }}
          GITHUB_REPOSITORY: ${{ secrets.GITHUB_REPOSITORY }}

