From 30ead69c77e66c50f30c090fd75e0da7161853f1 Mon Sep 17 00:00:00 2001 From: DW8030 <99119424+EmperorPinguin@users.noreply.github.com> Date: Sun, 18 Aug 2024 13:39:12 +0200 Subject: [PATCH] Create autoupdate.yaml --- .github/workflows/autoupdate.yaml | 51 +++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 .github/workflows/autoupdate.yaml diff --git a/.github/workflows/autoupdate.yaml b/.github/workflows/autoupdate.yaml new file mode 100644 index 0000000..9f6207f --- /dev/null +++ b/.github/workflows/autoupdate.yaml @@ -0,0 +1,51 @@ +name: Autoupdate + +on: + # Triggers the workflow on push or pull request events but only for the "master" branch + push: + branches: [ "master" ] + schedule: + - cron: '30 2 * * *' # Run once per day + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + unciv-lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: oxipng image compression # This needs to be before the Unciv run since that packs images + run: | + oxipng_url=$(curl -s https://api.github.com/repos/shssoichiro/oxipng/releases/latest | grep -o "http.*x86_64-unknown-linux-gnu.tar.gz") + wget -O oxipng.tar.gz $oxipng_url + tar -xvzf oxipng.tar.gz + rm oxipng.tar.gz + + # We're left with a folder named like "oxipng-9.1.2-x86_64-unknown-linux-gnu" which contains the actual executable + # So we find the file, run it on all png files in "Images" folders, and then delete the folder so it won't be a git diff + oxipng_file=$(find oxipng* | grep "/oxipng") + find Images* -type f -regex ".*png" | xargs -d '\n' $oxipng_file --opt max --strip all --alpha + rm -rf $(ls -1 | grep oxipng) + + - uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: 17 + + # Runs a set of commands using the runners shell + - name: Autoupdate + continue-on-error: true # We want to autoupdate even if there are errors + run: | + unciv_url=$(curl -s https://api.github.com/repos/yairm210/unciv/releases/latest | grep -o "http.*Unciv.jar") + wget -q -O Unciv.jar $unciv_url + java -jar Unciv.jar mod-ci + + - name: Remove Unciv executable + run: rm Unciv.jar + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v6 + with: + commit-message: Autoupdate