Skip to content

Commit 9a641a0

Browse files
committed
refix coverage test
1 parent d5a2ecb commit 9a641a0

1 file changed

Lines changed: 21 additions & 11 deletions

File tree

.github/workflows/code-coverage.yml

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111
- "feature/*"
1212
paths-ignore:
1313
- "**/README.md"
14-
- "coverage-badge.svg" # prevent loops when the bot updates the badge
14+
- "coverage-badge.svg" # prevent loops when the badge PR merges
1515
pull_request:
1616
branches:
1717
- "main"
@@ -27,7 +27,7 @@ jobs:
2727
with:
2828
ref: ${{ github.ref }}
2929
fetch-depth: 0
30-
persist-credentials: false # we'll rely on the action to commit/push
30+
persist-credentials: false # let CPR push with the workflow token
3131

3232
- name: Setup .NET
3333
uses: actions/setup-dotnet@v4
@@ -55,19 +55,19 @@ jobs:
5555
name: code-coverage-report
5656
path: coverage
5757

58-
- name: Prepare single-file badge for repo root (only on main)
58+
- name: Prepare badge for repo root (only on main)
5959
if: github.ref == 'refs/heads/main'
60-
run: |
61-
cp coverage/badge_linecoverage.svg ./coverage-badge.svg
60+
run: cp coverage/badge_linecoverage.svg ./coverage-badge.svg
6261

63-
# Create/update a PR containing only the badge file. The action handles commits & pushes.
62+
# Create or update a PR that contains ONLY the badge file
6463
- name: Open / update PR with coverage badge (only on main)
6564
if: github.ref == 'refs/heads/main'
6665
id: cpr
6766
uses: peter-evans/create-pull-request@v6
6867
with:
69-
branch: ci/update-coverage-badge
70-
base: main
68+
token: ${{ secrets.GITHUB_TOKEN }} # explicit to avoid 403s
69+
branch: ci/update-coverage-badge # PR head branch
70+
base: main # PR base branch
7171
title: "Update coverage badge"
7272
commit-message: "Update coverage badge"
7373
body: "Automated update of coverage-badge.svg"
@@ -77,6 +77,16 @@ jobs:
7777
ci
7878
automated
7979
80-
- name: Print PR URL
81-
if: steps.cpr.outputs.pull-request-url
82-
run: echo "${{ steps.cpr.outputs.pull-request-url }}"
80+
- name: Report CPR result
81+
run: |
82+
echo "result=${{ steps.cpr.outputs.result }}"
83+
echo "pr=${{ steps.cpr.outputs.pull-request-url || 'no PR (no changes)'}}"
84+
85+
# Optional: auto-merge the PR when allowed by your protections
86+
- name: Enable auto-merge for badge PR
87+
if: steps.cpr.outputs.pull-request-number
88+
uses: peter-evans/enable-pull-request-automerge@v3
89+
with:
90+
token: ${{ secrets.GITHUB_TOKEN }}
91+
pull-request-number: ${{ steps.cpr.outputs.pull-request-number }}
92+
merge-method: squash

0 commit comments

Comments
 (0)