Skip to content

Commit 68396dd

Browse files
committed
workflows: Tweak oidc auth for codecov
Currently codecov step succeeds in main and in PRs from forks, but fails in PRs from origin. This seems to be a codecov bug but I believe we can tweak the workaround. * Always run the auth workaround step * Only try to set the codecov token if OIDC is available This should mean that: * PRs from forks will not have auth token: that works fine * pushes to main will have auth token * PRs from origin repo will have auth token (even though they should not need it) Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
1 parent 82230be commit 68396dd

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

.github/workflows/test.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,10 @@ jobs:
8383
- name: Run Go tests
8484
run: go test -covermode atomic -coverprofile coverage.txt $(go list ./... | grep -v third_party/)
8585
- name: Workaround buggy Codecov OIDC auth
86-
if: github.event_name == 'push'
8786
run: |
87+
# only set CODECOV_TOKEN if OIDC token is available
88+
[ -z $ACTIONS_ID_TOKEN_REQUEST_TOKEN ] && exit 0
89+
8890
TOKEN_RESPONSE=$(curl -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" "$ACTIONS_ID_TOKEN_REQUEST_URL&audience=https://codecov.io")
8991
CODECOV_TOKEN=$(echo $TOKEN_RESPONSE | jq -r .value)
9092
echo "CODECOV_TOKEN=$CODECOV_TOKEN" >> "$GITHUB_ENV"

0 commit comments

Comments
 (0)