Skip to content

Merge pull request #74 from redBorder/feature/ip_identifier #27

Merge pull request #74 from redBorder/feature/ip_identifier

Merge pull request #74 from redBorder/feature/ip_identifier #27

Workflow file for this run

name: Update CHANGELOG
on:
push:
branches:
- master
jobs:
update-changelog:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Get PR information
id: pr_info
run: |
# Get the SHA of the latest commit
COMMIT_SHA=$(git rev-parse HEAD)
# Find the associated pull request for the commit
PR_NUMBER=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/${{ github.repository }}/commits/$COMMIT_SHA/pulls" \
| jq -r '.[0].number')
# Fetch pull request details
PR_TITLE=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/${{ github.repository }}/pulls/$PR_NUMBER" \
| jq -r '.title')
PR_BODY=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/${{ github.repository }}/pulls/$PR_NUMBER" \
| jq -r '.body')
PR_AUTHOR=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/${{ github.repository }}/pulls/$PR_NUMBER" \
| jq -r '.user.login')
echo "::set-output name=title::$PR_TITLE"
echo "::set-output name=body::$PR_BODY"
echo "::set-output name=author::$PR_AUTHOR"
- name: Update CHANGELOG
run: |
PR_TITLE="${{ steps.pr_info.outputs.title }}"
PR_BODY="${{ steps.pr_info.outputs.body }}"
PR_AUTHOR="${{ steps.pr_info.outputs.author }}"
TITLE="release - $(date +'%Y%m%d%H%M').0.0 - $(date +'%Y-%m-%d %H:%M:%S')"
echo "Updating CHANGELOG with Title: $TITLE"
echo "Author: $PR_AUTHOR" >> CHANGELOG.md
echo "$TITLE" >> CHANGELOG.md
echo "$PR_BODY" >> CHANGELOG.md
echo "" >> CHANGELOG.md # Add newline
git add CHANGELOG.md
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
git commit -m "chore: Update CHANGELOG after PR merge by $PR_AUTHOR [skip ci]" || exit 0
git push origin HEAD:${{ github.ref }}