Skip to content

ci: add 'Release PR Changelog' GitHub action #7

ci: add 'Release PR Changelog' GitHub action

ci: add 'Release PR Changelog' GitHub action #7

name: Update PR Comment with Changelog
on:
pull_request:
branches:
- master
jobs:
update-pr-comment:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install dependencies
run: npm install -g conventional-changelog-cli
- name: Generate Changelog
id: changelog
run: echo "::set-output name=changelog::$(conventional-changelog -s)"
- name: Get PR Number
run: echo "::set-output name=pr_number::${{ github.event.pull_request.number }}"
- name: Update PR comment
run: |
COMMENT="${{ steps.changelog.outputs.changelog }}"
PR_NUMBER=$(echo "${{ steps.pr_number.outputs.pr_number }}")
API_URL="https://api.github.com/repos/${{ github.repository }}/issues/$PR_NUMBER/comments"
echo "$COMMENT" > comment_body.txt
curl -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -H "Content-Type: application/json" -d "{\"body\": \"$(cat comment_body.txt)\"}" "$API_URL"