|
11 | 11 | - "feature/*" |
12 | 12 | paths-ignore: |
13 | 13 | - "**/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 |
15 | 15 | pull_request: |
16 | 16 | branches: |
17 | 17 | - "main" |
|
27 | 27 | with: |
28 | 28 | ref: ${{ github.ref }} |
29 | 29 | 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 |
31 | 31 |
|
32 | 32 | - name: Setup .NET |
33 | 33 | uses: actions/setup-dotnet@v4 |
@@ -55,19 +55,19 @@ jobs: |
55 | 55 | name: code-coverage-report |
56 | 56 | path: coverage |
57 | 57 |
|
58 | | - - name: Prepare single-file badge for repo root (only on main) |
| 58 | + - name: Prepare badge for repo root (only on main) |
59 | 59 | 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 |
62 | 61 |
|
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 |
64 | 63 | - name: Open / update PR with coverage badge (only on main) |
65 | 64 | if: github.ref == 'refs/heads/main' |
66 | 65 | id: cpr |
67 | 66 | uses: peter-evans/create-pull-request@v6 |
68 | 67 | 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 |
71 | 71 | title: "Update coverage badge" |
72 | 72 | commit-message: "Update coverage badge" |
73 | 73 | body: "Automated update of coverage-badge.svg" |
|
77 | 77 | ci |
78 | 78 | automated |
79 | 79 |
|
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