diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 67ed1fe..113ddea 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -35,32 +35,40 @@ jobs: run: | pytest --junitxml=pytest.xml --cov-report term-missing --cov=src tests/ | tee pytest-coverage.txt - - name: Generate coverage-report Branch AND README.md - id: generateCoverageReportBranch - if: success() # テスト成功時のみ実行 - run: | - # coverage-report ブランチが存在しない場合は作成 あればチェックアウト - if ! git ls-remote --exit-code origin coverage-report; then - git checkout --orphan coverage-report - git rm -rf . # すべてのファイルを削除 - else - git checkout coverage-report - fi - - name: Coverage Report id: CoverageReport if: success() # テスト成功時のみ実行 run: | - coverage-badge -o coverage.svg + coverage-badge -o .coverage.svg python - < README.md echo "" >> README.md echo "![test](coverage.svg)" >> README.md @@ -78,6 +86,14 @@ jobs: run: | git config --global user.name "github-actions[bot]" git config --global user.email "github-actions[bot]@users.noreply.github.com" + git add README.md coverage.svg - git commit -m "Update coverage report" - git push https://actions-bot:${{ secrets.CICD_GITEA_TOKEN }}@gitea.pglikers.com/data-science/cloud-run-job-base.git coverage-report --force + + # 変更があるかどうか確認(ステージング領域) + if git diff --cached --quiet; then + echo "No changes to commit" + else + git commit -m "Update coverage report" + git push https://actions-bot:${{ secrets.CICD_GITEA_TOKEN }}@gitea.pglikers.com/data-science/cloud-run-job-base.git coverage-report --force + fi +