|
1 | 1 | name: "3. Code Coverage" |
2 | 2 |
|
| 3 | +permissions: |
| 4 | + contents: write |
| 5 | + |
3 | 6 | on: |
4 | 7 | push: |
5 | 8 | branches: |
|
22 | 25 | with: |
23 | 26 | ref: ${{ github.ref }} |
24 | 27 | fetch-depth: 0 |
| 28 | + token: ${{ secrets.GITHUB_TOKEN }} |
25 | 29 |
|
26 | 30 | - name: Setup .NET |
27 | 31 | uses: actions/setup-dotnet@v4 |
@@ -55,25 +59,22 @@ jobs: |
55 | 59 | name: code-coverage-badge |
56 | 60 | path: coverage/badge_linecoverage.svg |
57 | 61 |
|
58 | | - - name: Commit coverage badge |
| 62 | + - name: Commit coverage badge (only on main) |
| 63 | + if: github.ref == 'refs/heads/main' |
59 | 64 | run: | |
60 | | - git config --global user.name 'github-actions[bot]' |
61 | | - git config --global user.email 'github-actions[bot]@users.noreply.github.com' |
| 65 | + git config --global user.name "github-actions[bot]" |
| 66 | + git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" |
62 | 67 |
|
63 | 68 | # Copy badge to root directory |
64 | | - find . -name badge_linecoverage.svg || echo "Badge not found" |
65 | 69 | cp coverage/badge_linecoverage.svg ./coverage-badge.svg |
66 | 70 |
|
67 | | - # Force add badge and commit |
68 | | - git add -f coverage-badge.svg |
69 | | - if git diff-index --cached --quiet HEAD; then |
70 | | - echo "No changes to commit" |
| 71 | + git add coverage-badge.svg |
| 72 | + if git diff --cached --quiet; then |
| 73 | + echo "No changes to commit" |
71 | 74 | else |
72 | | - git commit -m 'Update coverage badge' |
73 | | - git push --force |
| 75 | + git commit -m "Update coverage badge" |
| 76 | + git push |
74 | 77 | fi |
75 | | - env: |
76 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
77 | 78 |
|
78 | 79 | - name: Print Directory Structure |
79 | 80 | uses: FiorelaCiroku/XDTesting-Print-Directory-Structure@v1.0.2 |
0 commit comments