Skip to content

OpenTTD nightly

OpenTTD nightly #1502

name: OpenTTD nightly
on:
schedule:
- cron: '0 5 * * *'
workflow_dispatch:
jobs:
openttd-nightly:
name: OpenTTD nightly
runs-on: ubuntu-latest
steps:
- name: Check for new commit
id: new_commit
run: |
LATEST_RELEASE=$(curl -s https://cdn.openttd.org/openttd-nightlies/latest.yaml | grep "\- version: " | cut -b 12-)
YEAR=$(echo "${LATEST_RELEASE}" | cut -b1-4)
LATEST_REF=$(curl -s https://cdn.openttd.org/openttd-nightlies/${YEAR}/${LATEST_RELEASE}/changelog.txt | head -n 1 | cut -d\ -f2)
CURRENT_REF=$(curl -s https://api.github.com/repos/OpenTTD/OpenTTD/branches/master | jq -r .commit.sha)
if [ "${LATEST_REF}" != "${CURRENT_REF}" ]; then
BUILD_NIGHTLY=1
else
BUILD_NIGHTLY=0
fi
echo "Latest nightly ref: ${LATEST_REF}"
echo "Current ref of master: ${CURRENT_REF}"
echo "Build nightly: ${BUILD_NIGHTLY}"
echo "build_nightly=${BUILD_NIGHTLY}" >> $GITHUB_OUTPUT
- name: Generate access token
if: steps.new_commit.outputs.build_nightly != '0'
id: generate_token
uses: tibdex/github-app-token@v2
with:
app_id: ${{ secrets.DEPLOYMENT_APP_ID }}
private_key: ${{ secrets.DEPLOYMENT_APP_PRIVATE_KEY }}
installation_retrieval_mode: "repository"
installation_retrieval_payload: "OpenTTD/OpenTTD"
- name: Trigger 'Build nightly'
if: steps.new_commit.outputs.build_nightly != '0'
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ steps.generate_token.outputs.token }}
repository: OpenTTD/OpenTTD
event-type: Build nightly
client-payload: '{"ref": "master"}'