From b75cd5a7d9d62715c94e101ceddf7e4e7a8f9853 Mon Sep 17 00:00:00 2001 From: Alexander Kukushkin Date: Tue, 17 Jan 2023 15:28:39 +0100 Subject: [PATCH] Submit coverage to codacy only if secret is available (#2528) If PR is open from the external GH repo secrets are not set due to security reasons. It makes codacy coverage report to fail. Co-authored-by: Polina Bungina --- .github/workflows/tests.yaml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 771736304..a68e3b2f8 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -8,6 +8,10 @@ on: tags: - v.* +env: + CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }} + SECRETS_AVAILABLE: ${{ secrets.CODACY_PROJECT_TOKEN != '' }} + jobs: unit: runs-on: ${{ fromJson('{"ubuntu":"ubuntu-20.04","windows":"windows-latest","macos":"macos-latest"}')[matrix.os] }} @@ -147,8 +151,7 @@ jobs: run: python -m coverage xml -o cobertura.xml - name: Upload coverage to Codacy run: bash <(curl -Ls https://coverage.codacy.com/get.sh) report -r cobertura.xml -l Python --partial - env: - CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }} + if: ${{ env.SECRETS_AVAILABLE == 'true' }} coveralls-finish: name: Finalize coveralls.io @@ -167,5 +170,4 @@ jobs: runs-on: ubuntu-latest steps: - run: bash <(curl -Ls https://coverage.codacy.com/get.sh) final - env: - CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }} + if: ${{ env.SECRETS_AVAILABLE == 'true' }}