99 workflow_dispatch :
1010
1111permissions :
12- contents : write
12+ contents : write # needed to commit the badge
13+ pull-requests : write # needed to open/update the PR
1314
1415jobs :
1516 make-badge :
1617 runs-on : ubuntu-latest
1718
1819 steps :
19- - name : Check out default branch
20+ - name : Check out main (read-only; PR will target this)
2021 uses : actions/checkout@v4
2122 with :
22- ref : ${{ github.event.repository.default_branch }}
23+ ref : ${{ github.event.repository.default_branch }} # typically 'main'
2324 fetch-depth : 0
2425
2526 - name : Determine version and label
2627 id : meta
2728 shell : bash
2829 run : |
29- # Prefer the tag from a Release event
30+ set -e
3031 if [ "${{ github.event_name }}" = "release" ]; then
3132 VERSION="${{ github.event.release.tag_name }}"
3233 if [ "${{ github.event.release.prerelease }}" = "true" ]; then
@@ -35,16 +36,15 @@ jobs:
3536 LABEL="release"
3637 fi
3738 else
38- # Fallback for tag pushes / manual runs
3939 git fetch --tags --force --prune
4040 VERSION="$(git describe --tags --abbrev=0 2>/dev/null || echo 'v0.0.0')"
4141 LABEL="release"
4242 fi
4343
4444 echo "version=$VERSION" >> $GITHUB_OUTPUT
45- echo "label=$LABEL" >> $GITHUB_OUTPUT
45+ echo "label=$LABEL" >> $GITHUB_OUTPUT
4646
47- - name : Build SVG badge
47+ - name : Generate SVG badge
4848 shell : bash
4949 run : |
5050 set -e
@@ -53,11 +53,11 @@ jobs:
5353 LABEL='${{ steps.meta.outputs.label }}'
5454 VERSION='${{ steps.meta.outputs.version }}'
5555
56- # Simple width calculation (keeps everything repo-local)
56+ # Calculate widths for a Shields-like look
5757 label_chars=${#LABEL}
5858 vers_chars=${#VERSION}
59- label_w=$(( label_chars * 6 + 20 )) # ~6px per char + padding
60- right_w=$(( vers_chars * 8 + 20 )) # ~8px per char + padding
59+ label_w=$(( label_chars * 6 + 20 )) # ~6px/ char + padding
60+ right_w=$(( vers_chars * 8 + 20 )) # ~8px/ char + padding
6161 [ $label_w -lt 60 ] && label_w=60
6262 [ $right_w -lt 80 ] && right_w=80
6363 total_w=$(( label_w + right_w ))
8383 </svg>
8484 EOF
8585
86- - name : Commit badge
87- uses : stefanzweifel/git-auto-commit-action@v5
86+ # Create/refresh a PR with just the badge change
87+ - name : Open PR with badge update
88+ uses : peter-evans/create-pull-request@v6
8889 with :
89- commit_message : " chore: update release badge -> ${{ steps.meta.outputs.version }}"
90- file_pattern : Documentation/Images/release.svg
90+ commit-message : " chore: update release badge -> ${{ steps.meta.outputs.version }}"
91+ title : " chore: update release badge -> ${{ steps.meta.outputs.version }}"
92+ body : |
93+ Automated update of `Documentation/Images/release.svg`
94+ - **Label:** `${{ steps.meta.outputs.label }}`
95+ - **Version:** `${{ steps.meta.outputs.version }}`
96+ branch : " bot/release-badge/${{ steps.meta.outputs.version }}"
97+ base : ${{ github.event.repository.default_branch }}
98+ labels : automation, docs
99+ add-paths : |
100+ Documentation/Images/release.svg
0 commit comments