-
Notifications
You must be signed in to change notification settings - Fork 6
48 lines (42 loc) · 1.63 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
name: Pull Request Title Check
permissions:
contents: write
pull-requests: write
on:
pull_request:
types: [opened, reopened, synchronize]
jobs:
validate-pull-request-title:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Validate Pull Request Title
run: |
PR_TITLE=$(jq -r ".pull_request.title" "$GITHUB_EVENT_PATH")
# Check if the pull request title matches the required format
if ! echo "$PR_TITLE" | grep -qE '^(Added|Changed|Deprecated|Removed|Fixed|Security): .+$'; then
echo "Pull request title '$PR_TITLE' does not match the required format."
echo "::error::Pull request title does not match the required format."
exit 1
fi
- name: Extract Changelog Entry
id: extract_changelog_entry
run: |
PR_TITLE=$(jq -r ".pull_request.title" "$GITHUB_EVENT_PATH")
CATEGORY=$(echo "$PR_TITLE" | cut -d ':' -f 1)
CONTENT=$(echo "$PR_TITLE" | cut -d ':' -f 2-)
CHANGELOG_ENTRY="**${CATEGORY}**\n${CONTENT}"
- name: Update Changelog
env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
if: success()
run: |
# Update changelog file
sed -i "1s/^/${CHANGELOG_ENTRY}\n\n/" Changelog.md
# Commit and push changelog update
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add Changelog.md
git commit -m "Update Changelog with changes from pull request #$PR_NUMBER"
git push origin HEAD