Skip to content

Update THEOlive changelog #1699

Update THEOlive changelog

Update THEOlive changelog #1699

name: Update THEOlive changelog
on:
# Runs every hour
schedule:
- cron: '0 * * * *'
workflow_dispatch:
jobs:
update:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
env:
# The branch that will receive the changelog update (will be created if it doesn't exist)
# Will automatically open a new PR (if no PR exists yet)
UPDATE_BRANCH: update-theolive-changelog
steps:
- name: Create app token
uses: actions/create-github-app-token@v3
id: app-token
with:
client-id: ${{ vars.THEOPLAYER_BOT_CLIENT_ID }}
private-key: ${{ secrets.THEOPLAYER_BOT_PRIVATE_KEY }}
- name: Checkout
uses: actions/checkout@v7
with:
token: ${{ steps.app-token.outputs.token }}
fetch-depth: 1
- name: Configure Git user
run: |
git config user.name 'theoplayer-bot[bot]'
git config user.email '873105+theoplayer-bot[bot]@users.noreply.github.com'
- name: Create or checkout update branch
# language=bash
run: |
if git fetch --depth 1 origin refs/heads/$UPDATE_BRANCH ; then
git checkout -b $UPDATE_BRANCH FETCH_HEAD
else
git checkout -b $UPDATE_BRANCH HEAD
fi
- name: Fetch THEOlive changelog
run: |
curl -fsSL -o theolive/changelog.md \
'https://engine-changelog.s3.eu-west-3.amazonaws.com/CHANGELOG.md'
- name: Check for changes
id: check_changes
# language=bash
run: |
if git diff --quiet theolive/changelog.md; then
echo "No changelog changes detected."
else
echo "changed=true" >> "$GITHUB_OUTPUT"
fi
- name: Commit and push changes
if: ${{ steps.check_changes.outputs.changed }}
# language=bash
run: |
git add theolive/changelog.md
git commit -m 'Update THEOlive changelog'
git push --force origin HEAD:$UPDATE_BRANCH
- name: Check if pull request already exists
if: ${{ steps.check_changes.outputs.changed }}
id: check_pr_exists
# language=bash
run: |
pr_count=$(gh pr list --base main --head "$UPDATE_BRANCH" --state open --limit 1 --json number --jq length)
if ((pr_count > 0)); then
echo "exists=true" >> "$GITHUB_OUTPUT"
fi
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
- name: Create pull request
if: ${{ steps.check_changes.outputs.changed && !steps.check_pr_exists.outputs.exists }}
# language=bash
run: |
gh pr create \
--base main \
--head "$UPDATE_BRANCH" \
--title "Update THEOlive changelog" \
--body "This PR pulls in the latest THEOlive engine changelog."
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}