Skip to content

Add a github action to auto update the gradle wrapper #2

Add a github action to auto update the gradle wrapper

Add a github action to auto update the gradle wrapper #2

name: Update the gradle wrapper to the latest version
on:
push:
branches:
- 'update/**'
- 'dev/**'
pull_request:
schedule:
- cron: '0 0 * * 0'
jobs:
update-gradle-wrapper:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'adopt'
cache: gradle
- name: Get latest Gradle version
id: get_latest_gradle
run: |
response=$(curl -s https://services.gradle.org/versions/current)
latest_version=$(echo $response | jq -r '.version')
echo "LATEST_GRADLE_VERSION=$latest_version" >> $GITHUB_ENV
latest_download_url=$(echo $response | jq -r '.downloadUrl')
echo "LATEST_GRADLE_DOWNLOAD_URL=$latest_download_url" >> $GITHUB_ENV
- name: Update gradle.properties
run: |
sed -i "s|^distributionUrl=.*$|distributionUrl=${LATEST_GRADLE_DOWNLOAD_URL}|" gradle/wrapper/gradle-wrapper.properties
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build Skript and run test scripts
run: ./gradlew clean quickTest
- name: validate gradle wrapper
uses: gradle/wrapper-validation-action@v2
- name: Commit and push changes
if: success()
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add gradle/wrapper/gradle-wrapper.properties
git commit -m "Update Gradle wrapper to ${LATEST_GRADLE_VERSION}"
git push