From 7ff8c66a50230f45e5ce25141ac0169d09344819 Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Thu, 14 Nov 2024 21:59:57 -0500 Subject: [PATCH 01/12] fix: update tokenless branch logic --- action.yml | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index bcbc9b942..d7674a703 100644 --- a/action.yml +++ b/action.yml @@ -175,13 +175,29 @@ runs: echo "CODECOV_TOKEN=$CODECOV_TOKEN" >> $GITHUB_ENV fi fi + + - name: Override branch for forks + shell: bash + run: | + CC_BRANCH=${{ inputs.override_branch }} + + is_Fork=$(${{ github.event.pull_request.head.repo.full_name }} != ${{ github.repository }}) + if [ -z $CC_BRANCH ] && [ -z $CODECOV_TOKEN ] && [ "$is_fork" == "true" ]; + then + echo -e "\033[0;32m==>\033[0m Fork detected, tokenless uploading used" + TOKENLESS=${{ context.payload.pull_request.head.label }}; + CC_BRANCH=${{ context.payload.pull_request.head.label }}; + echo "TOKENLESS=$TOKENLESS" >> $GITHUB_ENV + echo "CC_BRANCH=$CC_BRANCH" >> $GITHUB_ENV + fi + - name: Upload coverage to Codecov run: ${GITHUB_ACTION_PATH}/dist/codecov.sh shell: bash working-directory: ${{ inputs.working-directory }} env: CC_BINARY: ${{ inputs.binary }} - CC_BRANCH: ${{ inputs.override_branch }} + CC_BRANCH: $CC_BRANCH CC_BUILD: ${{ inputs.override_build }} CC_BUILD_URL: ${{ inputs.override_build_url }} CC_CODE: ${{ inputs.report_code }} From 453bbab47995460b3d7c6b3228c6757ab641f180 Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Thu, 14 Nov 2024 22:06:40 -0500 Subject: [PATCH 02/12] fix: use the github context --- action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index d7674a703..b54f7c77b 100644 --- a/action.yml +++ b/action.yml @@ -185,8 +185,8 @@ runs: if [ -z $CC_BRANCH ] && [ -z $CODECOV_TOKEN ] && [ "$is_fork" == "true" ]; then echo -e "\033[0;32m==>\033[0m Fork detected, tokenless uploading used" - TOKENLESS=${{ context.payload.pull_request.head.label }}; - CC_BRANCH=${{ context.payload.pull_request.head.label }}; + TOKENLESS=${{ github.event.pull_request.head.label }}; + CC_BRANCH=${{ github.event.pull_request.head.label }}; echo "TOKENLESS=$TOKENLESS" >> $GITHUB_ENV echo "CC_BRANCH=$CC_BRANCH" >> $GITHUB_ENV fi From 7bee4bb711147b613372f9765b56e9ea336eecc2 Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Thu, 14 Nov 2024 22:08:03 -0500 Subject: [PATCH 03/12] fix: use double quotes --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index b54f7c77b..4ad3a8272 100644 --- a/action.yml +++ b/action.yml @@ -182,7 +182,7 @@ runs: CC_BRANCH=${{ inputs.override_branch }} is_Fork=$(${{ github.event.pull_request.head.repo.full_name }} != ${{ github.repository }}) - if [ -z $CC_BRANCH ] && [ -z $CODECOV_TOKEN ] && [ "$is_fork" == "true" ]; + if [ -z "$CC_BRANCH" ] && [ -z "$CODECOV_TOKEN" ] && [ "$is_fork" == "true" ]; then echo -e "\033[0;32m==>\033[0m Fork detected, tokenless uploading used" TOKENLESS=${{ github.event.pull_request.head.label }}; From 23d74e40278cb4a3634699a1f91195706da2d468 Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Thu, 14 Nov 2024 22:10:25 -0500 Subject: [PATCH 04/12] fix: lots of quotes --- action.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/action.yml b/action.yml index 4ad3a8272..9b9968d36 100644 --- a/action.yml +++ b/action.yml @@ -179,14 +179,14 @@ runs: - name: Override branch for forks shell: bash run: | - CC_BRANCH=${{ inputs.override_branch }} + CC_BRANCH="${{ inputs.override_branch }}" - is_Fork=$(${{ github.event.pull_request.head.repo.full_name }} != ${{ github.repository }}) + is_Fork=$("${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.repository }}") if [ -z "$CC_BRANCH" ] && [ -z "$CODECOV_TOKEN" ] && [ "$is_fork" == "true" ]; then echo -e "\033[0;32m==>\033[0m Fork detected, tokenless uploading used" - TOKENLESS=${{ github.event.pull_request.head.label }}; - CC_BRANCH=${{ github.event.pull_request.head.label }}; + TOKENLESS="${{ github.event.pull_request.head.label }}" + CC_BRANCH="${{ github.event.pull_request.head.label }}" echo "TOKENLESS=$TOKENLESS" >> $GITHUB_ENV echo "CC_BRANCH=$CC_BRANCH" >> $GITHUB_ENV fi From 7458bec9fc93a2ab07134b3ae286b3157eb5c97e Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Thu, 14 Nov 2024 22:12:56 -0500 Subject: [PATCH 05/12] fix: ai fixes --- action.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 9b9968d36..b559a0de4 100644 --- a/action.yml +++ b/action.yml @@ -180,13 +180,14 @@ runs: shell: bash run: | CC_BRANCH="${{ inputs.override_branch }}" + PR_HEAD_LABEL="${{ github.event.pull_request.head.label }}" is_Fork=$("${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.repository }}") if [ -z "$CC_BRANCH" ] && [ -z "$CODECOV_TOKEN" ] && [ "$is_fork" == "true" ]; then echo -e "\033[0;32m==>\033[0m Fork detected, tokenless uploading used" - TOKENLESS="${{ github.event.pull_request.head.label }}" - CC_BRANCH="${{ github.event.pull_request.head.label }}" + TOKENLESS="$PR_HEAD_LABEL" + CC_BRANCH="$PR_HEAD_LABEL" echo "TOKENLESS=$TOKENLESS" >> $GITHUB_ENV echo "CC_BRANCH=$CC_BRANCH" >> $GITHUB_ENV fi From 66a562f3474ca812c324a66a7bc1060525747617 Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Thu, 14 Nov 2024 22:15:13 -0500 Subject: [PATCH 06/12] fix: just shove it in --- action.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/action.yml b/action.yml index b559a0de4..766541314 100644 --- a/action.yml +++ b/action.yml @@ -182,8 +182,7 @@ runs: CC_BRANCH="${{ inputs.override_branch }}" PR_HEAD_LABEL="${{ github.event.pull_request.head.label }}" - is_Fork=$("${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.repository }}") - if [ -z "$CC_BRANCH" ] && [ -z "$CODECOV_TOKEN" ] && [ "$is_fork" == "true" ]; + if [ -z "$CC_BRANCH" ] && [ -z "$CODECOV_TOKEN" ] && [ "${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.repository }} ]; then echo -e "\033[0;32m==>\033[0m Fork detected, tokenless uploading used" TOKENLESS="$PR_HEAD_LABEL" From 41afb5f14f50c00fd183b3b3373d6f42befe8001 Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Thu, 14 Nov 2024 22:16:53 -0500 Subject: [PATCH 07/12] fix: more ai fixes --- action.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/action.yml b/action.yml index 766541314..10824e74a 100644 --- a/action.yml +++ b/action.yml @@ -179,17 +179,18 @@ runs: - name: Override branch for forks shell: bash run: | - CC_BRANCH="${{ inputs.override_branch }}" - PR_HEAD_LABEL="${{ github.event.pull_request.head.label }}" - if [ -z "$CC_BRANCH" ] && [ -z "$CODECOV_TOKEN" ] && [ "${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.repository }} ]; then echo -e "\033[0;32m==>\033[0m Fork detected, tokenless uploading used" - TOKENLESS="$PR_HEAD_LABEL" - CC_BRANCH="$PR_HEAD_LABEL" + TOKENLESS="$GITHUB_EVENT_PULL_REQUEST_HEAD_LABEL" + CC_BRANCH="$GITHUB_EVENT_PULL_REQUEST_HEAD_LABEL" echo "TOKENLESS=$TOKENLESS" >> $GITHUB_ENV echo "CC_BRANCH=$CC_BRANCH" >> $GITHUB_ENV fi + env: + GITHUB_EVENT_PULL_REQUEST_HEAD_LABEL: ${{ github.event.pull_request.head.label }} + CC_BRANCH: ${{ inputs.override_branch }} + CC_TOKEN: ${{ env.CODECOV_TOKEN }} - name: Upload coverage to Codecov run: ${GITHUB_ACTION_PATH}/dist/codecov.sh @@ -197,7 +198,7 @@ runs: working-directory: ${{ inputs.working-directory }} env: CC_BINARY: ${{ inputs.binary }} - CC_BRANCH: $CC_BRANCH + CC_BRANCH: ${{ env.CC_BRANCH }} CC_BUILD: ${{ inputs.override_build }} CC_BUILD_URL: ${{ inputs.override_build_url }} CC_CODE: ${{ inputs.report_code }} From 5873b3faedb079259245ae4ba6a972712d6922d9 Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Thu, 14 Nov 2024 22:17:24 -0500 Subject: [PATCH 08/12] fix: missing double quote --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 10824e74a..a77ce864e 100644 --- a/action.yml +++ b/action.yml @@ -179,7 +179,7 @@ runs: - name: Override branch for forks shell: bash run: | - if [ -z "$CC_BRANCH" ] && [ -z "$CODECOV_TOKEN" ] && [ "${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.repository }} ]; + if [ -z "$CC_BRANCH" ] && [ -z "$CODECOV_TOKEN" ] && [ "${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.repository }}" ]; then echo -e "\033[0;32m==>\033[0m Fork detected, tokenless uploading used" TOKENLESS="$GITHUB_EVENT_PULL_REQUEST_HEAD_LABEL" From 9301ab051930cc01e6bb8653208e56246571ee32 Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Thu, 14 Nov 2024 22:19:11 -0500 Subject: [PATCH 09/12] fix: more clenaup --- action.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index a77ce864e..3e561756f 100644 --- a/action.yml +++ b/action.yml @@ -179,7 +179,7 @@ runs: - name: Override branch for forks shell: bash run: | - if [ -z "$CC_BRANCH" ] && [ -z "$CODECOV_TOKEN" ] && [ "${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.repository }}" ]; + if [ -z "$CC_BRANCH" ] && [ -z "$CODECOV_TOKEN" ] && [ "${GITHUB_EVENT_PULL_REQUEST_REPO_FULL_NAME}" != "$GITHUB_REPOSITORY" ]; then echo -e "\033[0;32m==>\033[0m Fork detected, tokenless uploading used" TOKENLESS="$GITHUB_EVENT_PULL_REQUEST_HEAD_LABEL" @@ -188,9 +188,11 @@ runs: echo "CC_BRANCH=$CC_BRANCH" >> $GITHUB_ENV fi env: - GITHUB_EVENT_PULL_REQUEST_HEAD_LABEL: ${{ github.event.pull_request.head.label }} CC_BRANCH: ${{ inputs.override_branch }} CC_TOKEN: ${{ env.CODECOV_TOKEN }} + GITHUB_EVENT_PULL_REQUEST_HEAD_LABEL: ${{ github.event.pull_request.head.label }} + GITHUB_EVENT_PULL_REQUEST_REPO_FULL_NAME: ${{ github.event.pull_request.repo.full_name }} + GITHUB_REPOSITORY: ${{ github.repository }} - name: Upload coverage to Codecov run: ${GITHUB_ACTION_PATH}/dist/codecov.sh From 32a61294b6dd7799b6094e24d689b77f98ba6614 Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Thu, 14 Nov 2024 22:20:44 -0500 Subject: [PATCH 10/12] fix: add CC_BRANCH setting for not forks --- action.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 3e561756f..d1c2b089b 100644 --- a/action.yml +++ b/action.yml @@ -185,8 +185,9 @@ runs: TOKENLESS="$GITHUB_EVENT_PULL_REQUEST_HEAD_LABEL" CC_BRANCH="$GITHUB_EVENT_PULL_REQUEST_HEAD_LABEL" echo "TOKENLESS=$TOKENLESS" >> $GITHUB_ENV - echo "CC_BRANCH=$CC_BRANCH" >> $GITHUB_ENV fi + + echo "CC_BRANCH=$CC_BRANCH" >> $GITHUB_ENV env: CC_BRANCH: ${{ inputs.override_branch }} CC_TOKEN: ${{ env.CODECOV_TOKEN }} From 7cb957dfd8352ea3d9ce94ec934d82e3c82372d8 Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Thu, 14 Nov 2024 22:22:34 -0500 Subject: [PATCH 11/12] fix: cleanup --- action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index d1c2b089b..572cd18e4 100644 --- a/action.yml +++ b/action.yml @@ -190,7 +190,7 @@ runs: echo "CC_BRANCH=$CC_BRANCH" >> $GITHUB_ENV env: CC_BRANCH: ${{ inputs.override_branch }} - CC_TOKEN: ${{ env.CODECOV_TOKEN }} + CC_TOKEN: $CODECOV_TOKEN GITHUB_EVENT_PULL_REQUEST_HEAD_LABEL: ${{ github.event.pull_request.head.label }} GITHUB_EVENT_PULL_REQUEST_REPO_FULL_NAME: ${{ github.event.pull_request.repo.full_name }} GITHUB_REPOSITORY: ${{ github.repository }} @@ -201,7 +201,7 @@ runs: working-directory: ${{ inputs.working-directory }} env: CC_BINARY: ${{ inputs.binary }} - CC_BRANCH: ${{ env.CC_BRANCH }} + CC_BRANCH: $CC_BRANCH CC_BUILD: ${{ inputs.override_build }} CC_BUILD_URL: ${{ inputs.override_build_url }} CC_CODE: ${{ inputs.report_code }} From 50e2f8a6c1b105560f66f22c7f90bf6a4c61a171 Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Thu, 14 Nov 2024 22:44:11 -0500 Subject: [PATCH 12/12] fix: more cleanup --- action.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/action.yml b/action.yml index 572cd18e4..a2959d073 100644 --- a/action.yml +++ b/action.yml @@ -190,7 +190,6 @@ runs: echo "CC_BRANCH=$CC_BRANCH" >> $GITHUB_ENV env: CC_BRANCH: ${{ inputs.override_branch }} - CC_TOKEN: $CODECOV_TOKEN GITHUB_EVENT_PULL_REQUEST_HEAD_LABEL: ${{ github.event.pull_request.head.label }} GITHUB_EVENT_PULL_REQUEST_REPO_FULL_NAME: ${{ github.event.pull_request.repo.full_name }} GITHUB_REPOSITORY: ${{ github.repository }}