Skip to content

Update Changelog

Update Changelog #158

Workflow file for this run

name: Update Changelog
on:
schedule:
- cron: '0 0 * * *' # This will run the action every day at midnight
workflow_dispatch: # If we need to run the action manually
permissions:
contents: read
jobs:
update-changelog:
if: github.repository == 'aws-games/cloud-game-development-toolkit'
concurrency:
group: changelog-build
permissions:
contents: write # Used to create temporary branch for changelog updates
pull-requests: write # Used to create PRs for changelog updates
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.BOT_PAT }}
- name: Update Changelog
env:
GH_TOKEN: ${{ secrets.BOT_PAT }}
FILE_TO_COMMIT: CHANGELOG.md
DESTINATION_BRANCH: changelog-${{ github.run_id }}
run: |
git fetch --tags origin
docker run --rm -v $(pwd):/workdir quay.io/git-chglog/git-chglog -o CHANGELOG.md
export TODAY=$( date -u '+%Y-%m-%d' )
export MESSAGE="chore: regenerate $FILE_TO_COMMIT for $TODAY"
export CONTENT=$( base64 -i $FILE_TO_COMMIT )
export BRANCH_SHA=$( gh api /repos/:owner/:repo/git/ref/heads/main | jq .object.sha | tr -d '"')
gh api --method POST /repos/:owner/:repo/git/refs \
--field "ref=refs/heads/$DESTINATION_BRANCH" \
--field "sha=$BRANCH_SHA"
export SHA=$( gh api -XGET /repos/:owner/:repo/contents/$FILE_TO_COMMIT -F ref=refs/heads/$DESTINATION_BRANCH | jq .sha | tr -d '"')
gh api --method PUT /repos/:owner/:repo/contents/$FILE_TO_COMMIT \
--field message="$MESSAGE" \
--field content="$CONTENT" \
--field encoding="base64" \
--field branch="$DESTINATION_BRANCH" \
--field sha=$SHA
gh pr create --title "chore: update changelog" --body "This is an auto-generated PR to update the changelog." --base main --head $DESTINATION_BRANCH