-
Notifications
You must be signed in to change notification settings - Fork 1
50 lines (43 loc) · 1.62 KB
/
changelog.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
name: Update Plugin Changelog
on:
pull_request:
types:
- closed
jobs:
update-changelog:
if: github.event.pull_request.merged == true
runs-on: ubuntu-22.04
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Install Ruby and Dependencies
run: |
sudo apt-get update && sudo apt-get install -y ruby-full subversion
sudo gem install github_changelog_generator
- name: Generate Changelog
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
github_changelog_generator --user ${{ github.repository_owner }} --project ${{ github.event.repository.name }}
# Format the changelog for WordPress
awk '
BEGIN { print "== Changelog ==" }
{
gsub("## \\[(.*)\\] - (.*)", "= \\1 - \\2 =");
gsub("- ", "");
print;
}
' CHANGELOG.md > formatted_changelog.txt
- name: Update readme.txt
run: |
# Remove old changelog entries in readme.txt before appending new ones
sed -i '/== Changelog ==/,$d' readme.txt
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 -A
git status # Optional for debugging
git commit -m "Update changelog for version ${{ github.event.pull_request.head.ref }}" || echo "No changes to commit"
git push origin development || echo "Nothing to push"