Skip to content

Commit 4ee0c73

Browse files
committed
ci: Add actions to write to changelog.entries on each merged PRs
1 parent edcaaed commit 4ee0c73

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

.github/changelog.entries

Whitespace-only changes.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Update changelog on PR merge
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
branches:
7+
- master
8+
9+
jobs:
10+
update:
11+
if: github.event.pull_request.merged == true
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: write
15+
pull-requests: read
16+
steps:
17+
- id: check-title
18+
run: |
19+
PR_TITLE="${{ github.event.pull_request.title }}"
20+
PR_NUMBER=${{ github.event.pull_request.number }}
21+
PR_AUTHOR=${{ github.event.pull_request.user.login }}
22+
ALLOWED_PREFIXES="^(core|desktop|web|avm1|avm2|docs|chore|tests): " # more tags here
23+
if [[ ! "$PR_TITLE" =~ $ALLOWED_PREFIXES ]]; then
24+
echo "skip_collect=true" >> $GITHUB_OUTPUT
25+
exit 0
26+
fi
27+
echo "entry=$PR_TITLE" >> $GITHUB_OUTPUT
28+
echo "number=$PR_NUMBER" >> $GITHUB_OUTPUT
29+
echo "author=$PR_AUTHOR" >> $GITHUB_OUTPUT
30+
- name: Checkout repository
31+
if: steps.check-title.outputs.skip_collect != 'true'
32+
uses: actions/checkout@v6
33+
- name: Write to first line and push
34+
if: steps.check-title.outputs.skip_collect != 'true'
35+
run: |
36+
touch .github/changelog.entries
37+
sed -i "1i ${{ steps.check-title.outputs.entry }} by ${{ steps.check-title.outputs.author }} in #${{ steps.check-title.outputs.number }}" .github/changelog.entries
38+
git config user.name "github-actions[bot]"
39+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
40+
git add .github/changelog.entries
41+
git commit -m "ci: update changelog.entries"
42+
git push

0 commit comments

Comments
 (0)