name: Execute Gradle Wrapper Upgrade

on:
  schedule:
    - cron:  '0 2 * * *' # 2am UTC
  workflow_dispatch:

jobs:
  upgrade_wrapper:
    name: Execution
    runs-on: ubuntu-latest
    steps:
      - name: Set up Git configuration
        env:
          TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          git config --global url."https://unused-username:${TOKEN}@github.com/".insteadOf "https://github.com/"
          git config --global user.name 'github-actions[bot]'
          git config --global user.email 'github-actions[bot]@users.noreply.github.com'
      - name: Checkout
        uses: actions/checkout@v4
      - name: Set up JDK 17
        uses: actions/setup-java@v4
        with:
          java-version: '17'
          distribution: 'temurin'
      - name: Set up Gradle
        uses: gradle/gradle-build-action@v2
      - name: Upgrade Wrappers
        run: ./gradlew clean upgradeGradleWrapperAll --continue -Porg.gradle.java.installations.auto-download=false
        env:
          WRAPPER_UPGRADE_GIT_TOKEN: ${{ secrets.GITHUB_TOKEN }}
