Skip to content

Check for new releases #1183

Check for new releases

Check for new releases #1183

name: Check for new releases
on:
schedule:
- cron: '0 0 * * 0'
workflow_dispatch:
jobs:
check:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check for update
id: check
run: |
set -euo pipefail
# Blacksmith Check
BLACKSMITH_CURRENT_HASH=$(cat sources/BLACKSMITH)
BLACKSMITH_JSON="$(curl -fSsL http://cdn.darkanddarker.com/launcher/launcherinfo.json)"
BLACKSMITH_REMOTE_HASH=$(echo "$BLACKSMITH_JSON" | sha256sum | awk '{print $1}')
if [ "$BLACKSMITH_CURRENT_HASH" != "$BLACKSMITH_REMOTE_HASH" ]; then
echo "New release found!"
echo "blacksmith: $BLACKSMITH_CURRENT_HASH -> $BLACKSMITH_REMOTE_HASH"
echo "BS_DIGEST=$BLACKSMITH_REMOTE_HASH" >> $GITHUB_OUTPUT
echo 'new_release=true' >> $GITHUB_OUTPUT
echo "$BLACKSMITH_REMOTE_HASH" > sources/BLACKSMITH
else
echo "No new release found $BLACKSMITH_CURRENT_HASH -> $BLACKSMITH_REMOTE_HASH."
echo 'new_release=false' >> $GITHUB_OUTPUT
fi
- name: Setup Python
if: steps.check.outputs.new_release == 'true'
uses: actions/setup-python@v5
with:
cache: pip
python-version: '3.12'
- name: Install dependencies
if: steps.check.outputs.new_release == 'true'
run: pip install -r requirements.txt
- name: Generate release
if: steps.check.outputs.new_release == 'true'
id: generate
run: python dad_source_generate.py
- name: Save changes to repo
if: steps.check.outputs.new_release == 'true'
env:
GIT_AUTHOR_NAME: Flatpak External Data Checker
GIT_COMMITTER_NAME: Flatpak External Data Checker
# email sets "github-actions[bot]" as commit author, see https://github.community/t/github-actions-bot-email-address/17204/6
GIT_AUTHOR_EMAIL: 41898282+github-actions[bot]@users.noreply.github.com
GIT_COMMITTER_EMAIL: 41898282+github-actions[bot]@users.noreply.github.com
EMAIL: 41898282+github-actions[bot]@users.noreply.github.com
GITHUB_TOKEN: ${{ secrets.EXTERNAL_DATA_SECRET }}
run: |
git add .
git commit -m "Update blacksmith: ${{steps.check.outputs.BS_DIGEST}}"
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
id: cpr
if: steps.check.outputs.new_release == 'true'
env:
GIT_AUTHOR_NAME: Flatpak External Data Checker
GIT_COMMITTER_NAME: Flatpak External Data Checker
# email sets "github-actions[bot]" as commit author, see https://github.community/t/github-actions-bot-email-address/17204/6
GIT_AUTHOR_EMAIL: 41898282+github-actions[bot]@users.noreply.github.com
GIT_COMMITTER_EMAIL: 41898282+github-actions[bot]@users.noreply.github.com
EMAIL: 41898282+github-actions[bot]@users.noreply.github.com
GITHUB_TOKEN: ${{ secrets.EXTERNAL_DATA_SECRET }}
with:
token: ${{ secrets.EXTERNAL_DATA_SECRET }}
branch: automated/dad-update
delete-branch: true
title: Dark and Darker update
body: "blacksmith: ${{steps.check.outputs.BS_DIGEST}}"
- name: Automerge Pull Request
if: steps.check.outputs.new_release == 'true'
run: gh pr merge --rebase --auto "$PR_NUMBER"
env:
GH_TOKEN: ${{ secrets.EXTERNAL_DATA_SECRET }}
PR_NUMBER: ${{ steps.cpr.outputs.pull-request-number }}