Skip to content

Commit

Permalink
seperate steps for template comparsion and extract changelog
Browse files Browse the repository at this point in the history
Signed-off-by: Himani1519 <[email protected]>
  • Loading branch information
Himani1519 committed Oct 5, 2023
1 parent 1398742 commit 0134bfb
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 6 deletions.
41 changes: 36 additions & 5 deletions .github/workflows/build-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,25 +67,56 @@ jobs:
echo "ERROR: CHANGELOG.md has not been updated."
echo "::set-output name=check_commit::false"
fi
- name: Compare PR description with template
if: steps.check-changelog.outputs.check_commit == 'false'
run: |
PR_DESCRIPTION="${{ github.event.pull_request.body }}"
echo "$PR_DESCRIPTION" > /tmp/pr_description.txt
echo "PR DESCRIPTION saved to /tmp/pr_description.txt."
cat /tmp/pr_description.txt
# Save the template content to a file
TEMPLATE_CONTENT=$(sed 's/"//g' .github/pull_request_template.md)
echo "$TEMPLATE_CONTENT" > /tmp/template_content.txt
echo "Template content saved to /tmp/template_content.txt."
cat /tmp/template_content.txt
# Use diff to compare the two files
if diff -wB /tmp/pr_description.txt /tmp/template_content.txt > /dev/null; then
echo "ERROR: PR description is identical to the template."
exit 1
else
echo "PR description and template are different."
fi
- name: Extract changelog info
if: steps.check-changelog.outputs.check_commit == 'false'
id: extract-changelog
run: |
PR_DESCRIPTION="${{ github.event.pull_request.body }}"
PR_DESCRIPTION=$(cat /tmp/pr_description.txt)
# Check if "changelog:" exists in PR description
if echo "$PR_DESCRIPTION" | grep -q "VERSION:" && echo "$PR_DESCRIPTION" | grep -q "CHANGELOG:"; then
# Extract text after "changelog:"
# Extract content after "changelog:"
CHANGELOG_TEXT=$(echo $PR_DESCRIPTION | sed -n 's/.*CHANGELOG: \(.*\)/\1/p')
# Check if extracted CHANGELOG_TEXT is empty or identical to the template content
TEMPLATE_CONTENT=$(cat /tmp/template_content.txt)
if [ -z "$CHANGELOG_TEXT" ] || [ "$CHANGELOG_TEXT" == "$TEMPLATE_CONTENT" ]; then
echo "The changelog information after 'CHANGELOG:' cannot be empty or identical to pull_request_template.md."
exit 1
fi
# Extract VERSION: from PR description
VERSION=$(echo "$PR_DESCRIPTION" | grep -oP 'VERSION:\s*\K\d+\.\d+\.\d+')
VERSION=$(echo "$PR_DESCRIPTION" | grep -oP 'VERSION:\s*\K\d+\.\d+\.\d+')
echo "Extracted changelog: $CHANGELOG_TEXT"
echo "::set-output name=changelog::$CHANGELOG_TEXT"
echo "::set-output name=version::$VERSION"
else
echo -e "No changelog and version information found in PR description please add them.\n Expected Format:\n VERSION:X.XX.X\n CHANGELOG:This is changelog note.\n
To re-run the action, just make a push or commit after updating the PR description or updating the changelog via a manual file changing commit."
echo -e "No changelog and version information found in PR description. Please add them.\nExpected Format:\nVERSION:vX.XX.X\nCHANGELOG:This is changelog note.\nTo re-run the action, just make a push or commit after updating the PR description or updating the changelog via a manual file changing commit."
exit 1
fi
- name: Check PR body against changelog
if: steps.check-changelog.outputs.check_commit == 'false'
run: |
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Zlux Server Framework Changelog
# Zlux Server Framework Changelog

All notable changes to the Zlux Server Framework package will be documented in this file..
This repo is part of the app-server Zowe Component, and the change logs here may appear on Zowe.org in that section.
Expand Down

0 comments on commit 0134bfb

Please sign in to comment.