-
-
Notifications
You must be signed in to change notification settings - Fork 252
62 lines (54 loc) · 1.94 KB
/
changelog.yml
File metadata and controls
62 lines (54 loc) · 1.94 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
name: Populate Changelog
on:
pull_request:
types: [closed]
branches:
- develop
permissions:
contents: write
jobs:
Changelog:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Clone RocketPy
uses: actions/checkout@main
with:
repository: RocketPy-Team/RocketPy
ref: develop
token: ${{ secrets.RELEASE_TOKEN }}
- name: Update Changelog
env:
PR_TITLE: ${{ github.event.pull_request.title }}
PR_NUMBER: ${{ github.event.pull_request.number }}
PR_LABELS: ${{ join(github.event.pull_request.labels.*.name, ',') }}
run: |
SECTION="### Added"
PREFIX="ENH"
if [[ "$PR_LABELS" == *"Bug"* ]]; then
SECTION="### Fixed"
PREFIX="BUG"
elif [[ "$PR_LABELS" == *"Refactor"* ]]; then
SECTION="### Changed"
PREFIX="MNT"
elif [[ "$PR_LABELS" == *"Docs"* ]] && [[ "$PR_LABELS" == *"Git housekeeping"* ]]; then
SECTION="### Changed"
PREFIX="DOC"
elif [[ "$PR_LABELS" == *"Tests"* ]]; then
SECTION="### Changed"
PREFIX="TST"
elif [[ "$PR_LABELS" == *"Docs"* ]]; then
# Only documentation -> Added section
SECTION="### Added"
PREFIX="DOC"
fi
ENTRY="- $PREFIX: $PR_TITLE [#$PR_NUMBER](https://github.com/RocketPy-Team/RocketPy/pull/$PR_NUMBER)"
SECTION_LINE=$(grep -n "^$SECTION$" CHANGELOG.md | head -1 | cut -d: -f1)
sed -i "$((SECTION_LINE + 1))a\\$ENTRY" CHANGELOG.md
- name: Push Changes
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add CHANGELOG.md
git commit -m "DOC: Update Changelog for PR #${{ github.event.pull_request.number }}"
git push