@@ -157,28 +157,46 @@ runs:
157
157
- name : Action version
158
158
shell : bash
159
159
run : |
160
- CC_ACTION_VERSION=$(cat ${GITHUB_ACTION_PATH}/src/version | grep 'CODECOV_ACTION_VERSION=' | cut -d\" -f2 )
160
+ CC_ACTION_VERSION=$(cat ${GITHUB_ACTION_PATH}/src/version)
161
161
echo -e "\033[0;32m==>\033[0m Running Action version $CC_ACTION_VERSION"
162
162
- name : Set safe directory
163
163
if : ${{ inputs.disable_safe_directory != 'true' }}
164
164
shell : bash
165
165
run : |
166
166
git config --global --add safe.directory ${{ github.workspace }}
167
167
168
+ - name : Set fork
169
+ shell : bash
170
+ run : |
171
+ if [ -n "$GITHUB_EVENT_PULL_REQUEST_HEAD_REPO_FULL_NAME" ] && [ "${GITHUB_EVENT_PULL_REQUEST_HEAD_REPO_FULL_NAME}" != "$GITHUB_REPOSITORY" ];
172
+ then
173
+ echo -e "\033[0;32m==>\033[0m Fork detected"
174
+ CC_FORK="true"
175
+ echo "CC_FORK=$CC_FORK" >> "$GITHUB_ENV"
176
+ fi
177
+ env :
178
+ GITHUB_EVENT_PULL_REQUEST_HEAD_LABEL : ${{ github.event.pull_request.head.label }}
179
+ GITHUB_EVENT_PULL_REQUEST_HEAD_REPO_FULL_NAME : ${{ github.event.pull_request.head.repo.full_name }}
180
+ GITHUB_REPOSITORY : ${{ github.repository }}
181
+
182
+
168
183
- name : Get and set token
169
184
shell : bash
170
185
run : |
171
- if [ "${{ inputs.use_oidc }}" == 'true' ];
186
+ if [ "${{ inputs.use_oidc }}" == 'true' && "$CC_FORK" != 'true' ];
172
187
then
173
188
# {"count":1984,"value":"***"}
189
+ echo -e "\033[0;32m==>\033[0m Requesting OIDC token from ${ACTION_ID_TOKEN_REQUEST_URL}"
174
190
CC_TOKEN=$(curl -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" "$ACTIONS_ID_TOKEN_REQUEST_URL&audience=https://codecov.io" | cut -d\" -f6)
175
191
echo "CC_TOKEN=$CC_TOKEN" >> "$GITHUB_ENV"
176
192
elif [ -n "${{ env.CODECOV_TOKEN }}" ];
177
193
then
194
+ echo -e "\033[0;32m==>\033[0m Token from from env"
178
195
echo "CC_TOKEN=${{ env.CODECOV_TOKEN }}" >> "$GITHUB_ENV"
179
196
else
180
197
if [ -n "${{ inputs.token }}" ];
181
198
then
199
+ echo -e "\033[0;32m==>\033[0m Token set from input"
182
200
CC_TOKEN=$(echo "${{ inputs.token }}" | tr -d '\n')
183
201
echo "CC_TOKEN=$CC_TOKEN" >> "$GITHUB_ENV"
184
202
fi
@@ -187,7 +205,7 @@ runs:
187
205
- name : Override branch for forks
188
206
shell : bash
189
207
run : |
190
- if [ -z "$CC_BRANCH" ] && [ -z "$CC_TOKEN" ] && [ -n "$GITHUB_EVENT_PULL_REQUEST_HEAD_REPO_FULL_NAME" ] && [ "${GITHUB_EVENT_PULL_REQUEST_HEAD_REPO_FULL_NAME}" != "$GITHUB_REPOSITORY" ];
208
+ if [ -z "$CC_BRANCH" ] && [ -z "$CC_TOKEN" ] && [ "$CC_FORK" == 'true' ]
191
209
then
192
210
echo -e "\033[0;32m==>\033[0m Fork detected, tokenless uploading used"
193
211
TOKENLESS="$GITHUB_EVENT_PULL_REQUEST_HEAD_LABEL"
0 commit comments