Add initial implementation of PageFlash plugin with autoloading and admin features #19
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
name: Update Plugin Changelog | |
on: | |
pull_request: | |
types: | |
- closed | |
jobs: | |
update-changelog: | |
if: github.event.pull_request.merged == true | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
- name: Generate Formatted Changelog | |
run: | | |
# Check if CHANGELOG.md exists | |
if [ ! -f "CHANGELOG.md" ]; then | |
echo "CHANGELOG.md file not found" | |
exit 1 | |
fi | |
# Extract the changelog content starting from '# Changelog' | |
START_LINE=$(grep -n "^# Changelog" CHANGELOG.md | cut -d':' -f1) | |
if [ -z "$START_LINE" ]; then | |
echo "No '# Changelog' section found in CHANGELOG.md" | |
exit 1 | |
fi | |
# Extract the changelog entries, starting from the first '## ' section | |
tail -n +$((START_LINE + 1)) CHANGELOG.md > changelog_entries.txt | |
# Format the changelog entries into the desired format | |
awk ' | |
BEGIN { print "== Changelog ==" } | |
/^##/ { | |
if (version != "") { | |
print formatted_changelog; | |
} | |
version = $2; | |
date = $4; | |
formatted_changelog = "= " version " - " date " ="; | |
next; | |
} | |
/^- / { | |
gsub(/^- /, ""); | |
formatted_changelog = formatted_changelog "\n" $0; | |
} | |
END { | |
print formatted_changelog; | |
} | |
' changelog_entries.txt > formatted_changelog.txt | |
echo "Generated formatted changelog:" | |
cat formatted_changelog.txt | |
- name: Update readme.txt | |
run: | | |
# Check if readme.txt exists | |
if [ ! -f "readme.txt" ]; then | |
echo "readme.txt file not found" | |
exit 1 | |
fi | |
# Remove existing '== Changelog ==' and everything below it | |
sed -i '/== Changelog ==/,$d' readme.txt | |
# Add the new formatted changelog content | |
cat formatted_changelog.txt >> readme.txt | |
- name: Commit and Push Changes to GitHub | |
run: | | |
git config --global user.name "GitHub Actions" | |
git config --global user.email "github-actions@github.com" | |
git add readme.txt | |
git commit -m "Update changelog after merging PR #${{ github.event.pull_request.number }}" || echo "No changes to commit" | |
git push origin development || echo "Nothing to push" | |
- name: Cleanup formatted changelog | |
run: | | |
# Delete the formatted_changelog.txt file | |
if [ -f "formatted_changelog.txt" ]; then | |
rm formatted_changelog.txt | |
fi |