From 3016fcd20ef9584b4a5df411a77249076646afdd Mon Sep 17 00:00:00 2001 From: Drikus Roor Date: Thu, 7 Dec 2023 17:03:17 +0100 Subject: [PATCH] ci: Add coverage badge generation and push to separate branch only for main & develop --- .github/workflows/test.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 850ba5d1e..6273a1547 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,11 +12,17 @@ jobs: run: sudo docker-compose --env-file .env-github-actions run server bash -c "coverage run manage.py test" - name: Generate Backend Coverage Report (Inline) run: sudo docker-compose --env-file .env-github-actions run server bash -c "coverage report" - - name: Generate Backend Coverage Report (XML) + + # Generate coverage badge (only for main and develop branches) + - name: Generate Backend Coverage Report (XML) and Badge + if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' run: | sudo docker-compose --env-file .env-github-actions run server bash -c "coverage xml" sudo docker-compose --env-file .env-github-actions run server bash -c "genbadge coverage -i coverage.xml -o coverage-backend-badge-new.svg -n \"Backend Code Coverage\"" + + # Push coverage badge to separate branch (only for main and develop branches) - name: Push Backend Coverage Badge to separate branch + if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' run: | if git ls-remote --heads origin code-coverage-badges; then git fetch origin code-coverage-badges