From b2df0cce68c32f386c6f06a0fe014965df7c8a74 Mon Sep 17 00:00:00 2001 From: Drikus Roor Date: Thu, 7 Dec 2023 16:35:31 +0100 Subject: [PATCH] fix: Fix pushing backend code coverage badge to separate branch --- .github/workflows/test.yml | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e32ee1d5f..870842434 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,17 +15,22 @@ jobs: - name: Generate Backend Coverage Report (XML) 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.svg" - - name: Checkout code-coverage-badges branch - run: | - git checkout -b code-coverage-badges - git pull origin code-coverage-badges || true # ignore error if branch does not exist - - name: Copy XML Backend Coverage Badge + sudo docker-compose --env-file .env-github-actions run server bash -c "genbadge coverage -i coverage.xml -o coverage-backend-badge-new.svg" + - name: Push Backend Coverage Badge to separate branch run: | + if git ls-remote --heads origin code-coverage-badges; then + git fetch origin code-coverage-badges + git checkout code-coverage-badges + else + git checkout -b code-coverage-badges + git push origin code-coverage-badges + fi git config --global user.email "github-actions[bot]@users.noreply.github.com" git config --global user.name "github-actions[bot]" - git add coverage-backend-badge.svg - git commit -m "Add backend coverage badge" + rm backend/coverage-backend-badge.svg -f + mv backend/coverage-backend-badge-new.svg backend/coverage-backend-badge.svg + git add backend/coverage-backend-badge.svg + git commit -m "Add backend coverage badge for commit $GITHUB_SHA" git push origin code-coverage-badges frontend-test: