diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5b617a86dca2..19f84e023a5b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,9 +1,6 @@ name: Build on: [push, pull_request] -env: - COVERAGE_REPORT_PATH: "target/site/jacoco/jacoco.xml" - jobs: build: runs-on: ubuntu-latest @@ -16,8 +13,19 @@ jobs: distribution: 'adopt' - name: Build with Maven run: mvn --batch-mode --update-snapshots verify - - name: Upload coverage to codecov - uses: codecov/codecov-action@v3 + - name: Upload coverage to codecov (tokenless) + if: >- + github.event_name == 'pull_request' && + github.event.pull_request.head.repo.full_name != github.repository + uses: codecov/codecov-action@v4 + with: + fail_ci_if_error: true + - name: Upload coverage to codecov (with token) + if: > + github.repository == 'TheAlgorithms/Java' && + (github.event_name != 'pull_request' || + github.event.pull_request.head.repo.full_name == github.repository) + uses: codecov/codecov-action@v4 with: - files: "${{ env.REPORT_NAME }}" + token: ${{ secrets.CODECOV_TOKEN }} fail_ci_if_error: true