grabbing latest java server version #165
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: determine-java-server-version | |
run-name: grabbing latest java server version | |
on: | |
schedule: | |
- cron: 20 4 * * * | |
jobs: | |
run-minecraft-launcher: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 2 | |
- name: Setting permissions to execute script | |
run: chmod u+x start-mc-launcher.sh | |
- name: Start minecraft launcher and write new version file | |
run: ./start-mc-launcher.sh | |
- name: Check upon diff | |
id: check-diff | |
run: | | |
newVersionAvailable=$(git diff java_version_latest.json) | |
if [ -z "${newVersionAvailable}" ] | |
then | |
echo "NEW_VERSION=false" >> "$GITHUB_OUTPUT" | |
else | |
echo "NEW_VERSION=true" >> "$GITHUB_OUTPUT" | |
fi | |
- name: Commit and push new version when changed | |
run: | | |
if [ "${{ steps.check-diff.outputs.NEW_VERSION }}" == "true" ] | |
then | |
git config --global user.name '${{ github.actor }}' | |
git config --global user.email '${{ github.actor }}@users.noreply.github.com' | |
git commit -am "[automated] update java server version" | |
git push | |
else | |
echo "No new Minecraft Java Edition available." | |
fi |