Skip to content

Commit 2e2a9c6

Browse files
fix: update tokenless branch logic (#1650)
* fix: update tokenless branch logic * fix: use the github context * fix: use double quotes * fix: lots of quotes * fix: ai fixes * fix: just shove it in * fix: more ai fixes * fix: missing double quote * fix: more clenaup * fix: add CC_BRANCH setting for not forks * fix: cleanup * fix: more cleanup
1 parent cfc521b commit 2e2a9c6

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

action.yml

+20-1
Original file line numberDiff line numberDiff line change
@@ -175,13 +175,32 @@ runs:
175175
echo "CODECOV_TOKEN=$CODECOV_TOKEN" >> $GITHUB_ENV
176176
fi
177177
fi
178+
179+
- name: Override branch for forks
180+
shell: bash
181+
run: |
182+
if [ -z "$CC_BRANCH" ] && [ -z "$CODECOV_TOKEN" ] && [ "${GITHUB_EVENT_PULL_REQUEST_REPO_FULL_NAME}" != "$GITHUB_REPOSITORY" ];
183+
then
184+
echo -e "\033[0;32m==>\033[0m Fork detected, tokenless uploading used"
185+
TOKENLESS="$GITHUB_EVENT_PULL_REQUEST_HEAD_LABEL"
186+
CC_BRANCH="$GITHUB_EVENT_PULL_REQUEST_HEAD_LABEL"
187+
echo "TOKENLESS=$TOKENLESS" >> $GITHUB_ENV
188+
fi
189+
190+
echo "CC_BRANCH=$CC_BRANCH" >> $GITHUB_ENV
191+
env:
192+
CC_BRANCH: ${{ inputs.override_branch }}
193+
GITHUB_EVENT_PULL_REQUEST_HEAD_LABEL: ${{ github.event.pull_request.head.label }}
194+
GITHUB_EVENT_PULL_REQUEST_REPO_FULL_NAME: ${{ github.event.pull_request.repo.full_name }}
195+
GITHUB_REPOSITORY: ${{ github.repository }}
196+
178197
- name: Upload coverage to Codecov
179198
run: ${GITHUB_ACTION_PATH}/dist/codecov.sh
180199
shell: bash
181200
working-directory: ${{ inputs.working-directory }}
182201
env:
183202
CC_BINARY: ${{ inputs.binary }}
184-
CC_BRANCH: ${{ inputs.override_branch }}
203+
CC_BRANCH: $CC_BRANCH
185204
CC_BUILD: ${{ inputs.override_build }}
186205
CC_BUILD_URL: ${{ inputs.override_build_url }}
187206
CC_CODE: ${{ inputs.report_code }}

0 commit comments

Comments
 (0)