Update Changelog file #4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Update Changelog file | |
on: | |
workflow_dispatch: | |
release: | |
types: [published] | |
jobs: | |
update-changelog: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Get latest release tag | |
id: get_latest_release | |
run: echo "::set-output name=tag::$(gh release list -R ${{ github.repository }} --limit 1 --json tagName --jq '.[0].tagName')" | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Get release notes | |
id: get_release_notes | |
run: | | |
release_notes=$(gh release view ${{ steps.get_latest_release.outputs.tag }} -R ${{ github.repository }} --json body --jq '.body') | |
echo "::set-output name=notes::$release_notes" | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Update CHANGELOG.md | |
run: | | |
echo "## [${{ steps.get_latest_release.outputs.tag }}] - $(date +"%Y-%m-%d")" >> CHANGELOG.md | |
echo "${{ steps.get_release_notes.outputs.notes }}" >> CHANGELOG.md | |
echo "" >> CHANGELOG.md | |
- name: Create new branch | |
run: | | |
git checkout -b update-changelog-${{ steps.get_latest_release.outputs.tag }} | |
git add CHANGELOG.md | |
git commit -m 'Update CHANGELOG.md for ${{ steps.get_latest_release.outputs.tag }}' | |
git push -u origin update-changelog-${{ steps.get_latest_release.outputs.tag }} | |
- name: Create Pull Request | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
gh pr create \ | |
--title "Update CHANGELOG.md for ${{ steps.get_latest_release.outputs.tag }}" \ | |
--body "This PR updates the CHANGELOG.md file with the release notes for ${{ steps.get_latest_release.outputs.tag }}." \ | |
--head update-changelog-${{ steps.get_latest_release.outputs.tag }} \ | |
--base main |