Skip to content

Commit f451a12

Browse files
AbdulR3hmanAbdulRehman Faraj
authored andcommitted
Allow Tokenless CodeCov Upload to Forked PRs (awslabs#2946)
Co-authored-by: AbdulRehman Faraj <[email protected]>
1 parent fafa68e commit f451a12

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

.github/workflows/maven_push.yml

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,31 @@ jobs:
3737
- name: Identify any Maven Build changes
3838
run: >
3939
! (git status | grep "modified: " )
40-
- name: Upload coverage reports to Codecov
40+
41+
# -------- Codecov coverage upload --------
42+
# Fork PRs: upload WITHOUT token
43+
- name: Upload coverage reports to Codecov (fork PRs, no token)
44+
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork }}
4145
uses: codecov/codecov-action@v5
42-
env:
46+
47+
# Pushes & same-repo PRs: upload WITH token
48+
- name: Upload coverage reports to Codecov (internal only)
49+
if: ${{ github.event_name != 'pull_request' || (github.event_name == 'pull_request' && !github.event.pull_request.head.repo.fork) }}
50+
uses: codecov/codecov-action@v5
51+
with:
4352
slug: awslabs/aws-athena-query-federation
44-
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
45-
- name: Upload test results to Codecov
46-
if: ${{ !cancelled() }}
53+
token: ${{ secrets.CODECOV_TOKEN }}
54+
# -------- Codecov test results --------
55+
# Fork PRs: no token
56+
- name: Upload test results to Codecov (fork PRs, no token)
57+
if: ${{ !cancelled() && github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork }}
58+
uses: codecov/test-results-action@v1
59+
with:
60+
slug: awslabs/aws-athena-query-federation
61+
62+
# Pushes & same-repo PRs: with token
63+
- name: Upload test results to Codecov (internal only)
64+
if: ${{ !cancelled() && (github.event_name != 'pull_request' || (github.event_name == 'pull_request' && !github.event.pull_request.head.repo.fork)) }}
4765
uses: codecov/test-results-action@v1
4866
with:
4967
slug: awslabs/aws-athena-query-federation

codecov.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ codecov:
22
# Documentation: https://docs.codecov.com/docs/codecovyml-reference#codecov
33
# Always Validate the file before submitting a PR as follows:
44
# curl --data-binary @codecov.yml https://codecov.io/validate
5-
token: ${{ secrets.CODECOV_TOKEN }}
65
branch: master
76
coverage:
87
precision: 2

0 commit comments

Comments
 (0)