Skip to content

Check for updated Factorio version #217

Check for updated Factorio version

Check for updated Factorio version #217

name: Check for updated Factorio version
on:
schedule:
- cron: "0 6 * * *"
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
check-for-updated-version:
runs-on: ubuntu-latest
outputs:
updated: ${{ steps.check-updated.outputs.updated }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm ci
- run: npm run download-latest-api-jsons
- name: Check if factorio version updated
id: check-updated
run: if [[ `git status --porcelain -- generator/input` ]]; then echo "updated=true" >> $GITHUB_OUTPUT; echo "Version updated"; else echo "updated=false" >> $GITHUB_OUTPUT; echo "Nothing changed"; fi
create-pr:
runs-on: ubuntu-latest
needs: check-for-updated-version
if: ${{ needs.check-for-updated-version.outputs.updated == 'true' }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm ci
- run: npm run download-latest-api-jsons
- name: Get current version
run: echo "FACTORIO_VERSION=$(npx tsx ./scripts/get-current-version.ts )" >> $GITHUB_ENV
- run: npm run clean
- run: npm run generate || echo "Failed to generate, still creating PR"
- run: npm run new-version-changelog
- run: npm version minor --no-git-tag-version
- id: create-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.PRIVATE_KEY }}
- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
with:
base: main
commit-message: "Update to Factorio API version ${{ env.FACTORIO_VERSION }}"
title: "Update to Factorio API version ${{ env.FACTORIO_VERSION }}"
branch: factorio-version-${{ env.FACTORIO_VERSION }}
token: ${{ steps.create-token.outputs.token }}