-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Backport update to changelog.yml workflow
- Loading branch information
1 parent
1c5a0f8
commit cd1b283
Showing
1 changed file
with
28 additions
and
31 deletions.
There are no files selected for viewing
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
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 |