diff --git a/.github/workflows/shared-coverage.yml b/.github/workflows/shared-coverage.yml index 2e6ab23b7..ba387c8a8 100644 --- a/.github/workflows/shared-coverage.yml +++ b/.github/workflows/shared-coverage.yml @@ -52,6 +52,16 @@ jobs: path: cs-coverage merge-multiple: true + - name: Setup Git for Push + shell: bash + env: + BADGE_BRANCH: ${{ inputs.badge_branch || github.ref_name }} + run: | + git config --global --add safe.directory "$GITHUB_WORKSPACE" + git remote set-branches origin '*' + git fetch origin "$BADGE_BRANCH" + git branch --set-upstream-to="origin/$BADGE_BRANCH" "$BADGE_BRANCH" || true + - name: Generate Coverage Report shell: pwsh run: | diff --git a/scripts/coverage_report.py b/scripts/coverage_report.py index f225eded6..75f90d676 100644 --- a/scripts/coverage_report.py +++ b/scripts/coverage_report.py @@ -222,7 +222,10 @@ def git_commit_badges(badge_branch: str, ref_name: str) -> None: diff = run(["git", "diff", "--staged", "--quiet"]) if diff.returncode != 0: run(["git", "commit", "-m", "ci: update coverage badges"]) - run(["git", "push", "origin", f"HEAD:{target}"]) + result = run(["git", "push", "origin", f"HEAD:{target}"]) + if result.returncode != 0: + print(f"ERROR: git push failed:\n{result.stderr}", flush=True) + raise SystemExit(1) print(f"Committed and pushed badge updates to {target}") else: print("No badge changes to commit")