Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ on:
workflows: ["Rust CI"]
types:
- completed
branches:
- main

jobs:
update-badge:
Expand All @@ -18,7 +16,7 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: main
ref: ${{ github.event.workflow_run.head_branch }}

- name: Download coverage artifacts
uses: actions/download-artifact@v4
Expand Down Expand Up @@ -57,8 +55,19 @@ jobs:
mkdir -p .github/badges
echo "{\"schemaVersion\": 1, \"label\": \"coverage\", \"message\": \"${COVERAGE}%\", \"color\": \"$COLOR\"}" > .github/badges/coverage.json

# Commit and push the badge file
git config user.name github-actions
git config user.email github-actions@github.com
git add .github/badges/coverage.json
git diff --staged --quiet || (git commit -m "Update coverage badge [skip ci]" && git push)
# Only commit and push badge updates for non-main branches (PRs)
# For main branch, the badge will be updated when the PR merges
if [ "${{ github.event.workflow_run.head_branch }}" != "main" ]; then
git config user.name github-actions
git config user.email github-actions@github.com
git add .github/badges/coverage.json
if ! git diff --staged --quiet; then
git commit -m "Update coverage badge [skip ci]"
# Push to the PR branch
git push origin HEAD:${{ github.event.workflow_run.head_branch }}
else
echo "✅ No changes to coverage badge"
fi
else
echo "✅ Running on main branch - badge updates happen via PR merges"
fi