Skip to content

Commit

Permalink
Merge pull request #759 from AlexVelezLl/add-invisible-comment
Browse files Browse the repository at this point in the history
Backport needed changes to automate changelog updates in release-v4
  • Loading branch information
rtibbles authored Aug 28, 2024
2 parents bf04095 + cd1b283 commit 4424aa9
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 31 deletions.
59 changes: 28 additions & 31 deletions .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,31 @@
name: Check Changelog.md
name: Check PR for Changelog

on:
pull_request:
types: [opened, synchronize, reopened]
types: [opened, synchronize, edited, reopened]

jobs:
check-changelog:
runs-on: ubuntu-latest
permissions: write-all
steps:
- uses: actions/checkout@v4
- name: Fetch changed files
id: fetch-changed-files
run: |
response=$(gh api \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
repos/${owner}/${REPO}/pulls/${PULL_NUMBER}/files)
echo "$response" | jq '.' > response.json
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
owner: ${{ github.repository_owner }}
REPO: ${{ github.event.repository.name }}
PULL_NUMBER: ${{ github.event.pull_request.number }}
- name: Check if Changelog.md is changed
run: |
if [[ $(jq '.[].filename' response.json) == *"CHANGELOG.md"* ]]; then
echo "Changelog.md is changed"
exit 0
else
echo "Changelog.md is not changed"
exit 1
fi
check-description:
runs-on: ubuntu-latest
steps:

- name: Check PR Description
id: check_description
run: |
description=$(jq -r ".pull_request.body" "$GITHUB_EVENT_PATH" | awk '/## Changelog/{flag=1; next} /##/{flag=0} flag' | grep -oP '(?<=- \*\*Description:\*\* ).*' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
echo "$description"
default_description="Summary of change(s)"
if [ -n "$description" ] && [ "$description" != "$default_description" ]; then
echo "containsChangelog=true" >> $GITHUB_OUTPUT
else
echo "containsChangelog=false" >> $GITHUB_OUTPUT
fi
- name: Results
run: |
if [[ "${{ steps.check_description.outputs.containsChangelog }}" == "true" || "${{ github.event.pull_request.user.login }}" == "dependabot[bot]" ]]; then
echo "PR contains Changelog section/ PR made by Dependabot"
exit 0
else
echo "Changelog section is missing or does not contain the required details"
exit 1
fi
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Changelog is rather internal in nature. See release notes for the public overvie

## Version 4.x.x (`release-v4` branch)

<!-- [DO NOT REMOVE-USED BY GH ACTION] PASTE CHANGELOG -->

- [#737]
- **Description:** Bump KDS version to 4.4.1.
Expand Down

0 comments on commit 4424aa9

Please sign in to comment.