Created
June 16, 2021 16:57
-
-
Save jamesckemp/9cc946b456b4f5dfd09c0d232af79f09 to your computer and use it in GitHub Desktop.
Add pull request title to end of changelog file on PR merge
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
on: | |
pull_request: | |
branches: | |
- dev | |
types: [closed] | |
jobs: | |
update_changelog: | |
name: Update and Commit Changelog | |
runs-on: ubuntu-latest | |
if: github.event.pull_request.merged == true | |
steps: | |
# Checkout git. | |
- uses: actions/checkout@v2 | |
with: | |
ref: dev # checkout dev branch. | |
fetch-depth: 0 # fetch all history. | |
- run: git config --global user.email "[email protected]" | |
- run: git config --global user.name "SomeUsername" | |
- name: Create Changelog Entry String | |
run: | | |
cl_entry="${{ github.event.pull_request.title }} " | |
cl_entry="${cl_entry//'%'/'%25'}" | |
cl_entry="${cl_entry//$'\n'/'%0A'}" | |
cl_entry="${cl_entry//$'\r'/'%0D'}" | |
echo "::set-output name=content::$cl_entry" | |
id: changelog | |
# Update changelog. | |
- run: | | |
echo "${{ steps.changelog.outputs.content }}" >> changelog-dev.md | |
# Commit changes. | |
- run: git add changelog-dev.md | |
- run: git commit -m "Update Changelog" || echo "No changes to commit" | |
- run: git push origin dev |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment