Skip to content

Commit 1365dce

Browse files
committed
Improved token selectioon for codecov upload
1 parent ad2ef4a commit 1365dce

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

.github/workflows/test-go-task.yml

+15-17
Original file line numberDiff line numberDiff line change
@@ -92,25 +92,23 @@ jobs:
9292
GO_MODULE_PATH: ${{ matrix.module.path }}
9393
run: task go:test
9494

95-
# A token is used to avoid intermittent spurious job failures caused by rate limiting.
96-
- name: Set up Codecov upload token
97-
run: |
98-
if [[ "${{ github.repository }}" == "arduino/pluggable-discovery-protocol-handler" ]]; then
99-
# In order to avoid uploads of data from forks, only use the token for runs in this repo.
100-
# Token is intentionally exposed.
101-
# See: https://community.codecov.com/t/upload-issues-unable-to-locate-build-via-github-actions-api/3954
102-
CODECOV_TOKEN="d2497f03-291d-4e0c-9d31-d94614ed7c16"
103-
else
104-
# codecov/codecov-action does unauthenticated upload if empty string is passed via the `token` input.
105-
CODECOV_TOKEN=""
106-
fi
107-
echo "CODECOV_TOKEN=$CODECOV_TOKEN" >> "$GITHUB_ENV"
108-
10995
- name: Send unit tests coverage to Codecov
110-
if: runner.os == 'Linux'
96+
if: runner.os == 'Linux' && github.repository == 'arduino/pluggable-discovery-protocol-handler'
97+
uses: codecov/codecov-action@v3
98+
with:
99+
# A token is used to avoid intermittent spurious job failures caused by rate limiting.
100+
token: d2497f03-291d-4e0c-9d31-d94614ed7c16
101+
file: ${{ matrix.module.path }}coverage_unit.txt
102+
flags: ${{ matrix.module.codecov-flags }}
103+
fail_ci_if_error: true
104+
105+
- name: Send unit tests coverage to Codecov (run from a fork)
106+
if: runner.os == 'Linux' && github.repository != 'arduino/pluggable-discovery-protocol-handler'
111107
uses: codecov/codecov-action@v3
112108
with:
113-
token: ${{ env.CODECOV_TOKEN }}
109+
# use repository variable CODECOV_TOKEN if running from a fork.
110+
# codecov/codecov-action does unauthenticated upload if empty string is passed via the `token` input.
111+
token: ${{ vars.CODECOV_TOKEN }}
114112
file: ${{ matrix.module.path }}coverage_unit.txt
115113
flags: ${{ matrix.module.codecov-flags }}
116-
fail_ci_if_error: ${{ github.repository == 'arduino/pluggable-discovery-protocol-handler' }}
114+
fail_ci_if_error: false

0 commit comments

Comments
 (0)