Skip to content

Instantly share code, notes, and snippets.

@jamesckemp
Created June 16, 2021 16:57
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamesckemp/9cc946b456b4f5dfd09c0d232af79f09 to your computer and use it in GitHub Desktop.
Save jamesckemp/9cc946b456b4f5dfd09c0d232af79f09 to your computer and use it in GitHub Desktop.
Add pull request title to end of changelog file on PR merge
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 "your@email.com"
- 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