name: OpenOSRS - Gradle Dependencies

on:
  schedule:
    - cron: 0 0 * * *

jobs:
  update-wrapper:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2.3.4
      - name: Make gradlew executable
        run: chmod +x ./gradlew
      - name: Update Gradle Wrapper
        run: ./gradlew wrapper --gradle-version $(curl -s https://api.github.com/repos/gradle/gradle/releases/latest | grep -Po '"name":.*?[^\\]",' | sed -r 's/[\"name:, ]+//g') --distribution-type all --console=plain
      - name: Create Gradle wrapper update Pull Request
        uses: peter-evans/create-pull-request@v3.4.1
        with:
          token: ${{ secrets.OpenOSRS }}
          author: OpenOSRS <openosrs.github@gmail.com>
          committer: OpenOSRS <openosrs.github@gmail.com>
          branch: GRADLE-WRAPPER-UPDATE
          commit-message: 'gradle: Update gradle wrapper'
          title: 'gradle: Update gradle wrapper'
          body: This is an auto-generated PR with an updated gradle version
          labels: automated-pull-request, gradle
          signoff: false
