-
Notifications
You must be signed in to change notification settings - Fork 57
59 lines (57 loc) · 2.33 KB
/
breaking-change-description-title-update.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
51
52
53
54
55
56
57
58
59
name: "Update Breaking Change With Conventional Commits"
on:
pull_request:
types:
- opened
- reopened
- edited
- synchronize
# cancel redundant builds
concurrency:
group: "update-breaking-change-${{ github.ref }}"
cancel-in-progress: true
jobs:
update_pr:
# we want this to only run on breaking-release PRs
if: contains(github.head_ref, 'release-please') != true && contains(github.head_ref, 'breaking-release') == true
runs-on: ubuntu-latest
steps:
- uses: 8BitJonny/gh-get-current-pr@3
with:
sha: ${{ github.event.pull_request.head.sha }}
id: PR
- uses: actions/checkout@v4
with:
fetch-depth: 0
- run: |
pr_body=$(cat << EOF
${{ steps.PR.outputs.pr_body }}
EOF
)
delimiter="Changelog picked up from commits here:"
cleaned_body="${pr_body%${delimiter}*}"
cleaned_body_without_trailing_space="$(python .github/remove_trailing_space.py "${cleaned_body}")"
conventional_commits="$(git log --pretty=format:"%B" origin/main..HEAD | grep -Pio '^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test|¯\\_\(ツ\)_\/¯)(\(\w+\)?((?=:\s)|(?=!:\s)))?(!)?(:\s.*)?(\n\n.*)?$' | grep ':' || true)"
title="$(python .github/breaking_change_title.py "${conventional_commits}")"
echo "CONVENTIONAL_TITLE=${title}" >> $GITHUB_ENV
remaining_commits="$(python .github/breaking_change_description.py "${conventional_commits}")"
echo "MODIFIED_BODY<<EOF" >> $GITHUB_ENV
echo "${cleaned_body_without_trailing_space}" >> ${GITHUB_ENV}
if [ ${#remaining_commits} -gt 0 ]; then
echo "" >> ${GITHUB_ENV}
echo "${delimiter}" >> ${GITHUB_ENV}
echo "" >> ${GITHUB_ENV}
echo "${remaining_commits}" >> $GITHUB_ENV
fi
echo 'EOF'>> $GITHUB_ENV
- uses: tzkhan/pr-update-action@v2
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
# added this though it isn't used
base-branch-regex: '[a-z\d-_.\\/]+'
body-template: |
${{ env.MODIFIED_BODY }}
body-update-action: 'replace'
body-uppercase-base-match: false
title-update-action: 'replace'
title-template: ${{ env.CONVENTIONAL_TITLE }}