Skip to content

Update Changelog

Update Changelog #152

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@a5ac7e51b41094c92402da3b24376905380afc29
with:
fetch-depth: 0
- name: Update Changelog
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
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