From c28c79e0f1312665d8f6f025c85a8eae8f9f6c2c Mon Sep 17 00:00:00 2001 From: Yeela Lifshitz Date: Sun, 16 Mar 2025 20:46:34 +0200 Subject: [PATCH 1/4] Add checkout step for cm organization in action.yml --- action.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/action.yml b/action.yml index 5413eb92..e99d8e2c 100644 --- a/action.yml +++ b/action.yml @@ -151,6 +151,15 @@ runs: ref: ${{ fromJSON(fromJSON(inputs.client_payload)).cmRepoRef }} path: gitstream/cm/ + - name: Checkout cm org + uses: actions/checkout@v4 + if: ${{ fromJSON(fromJSON(inputs.client_payload)).hasCmOrg == true && (env.SKIP_GIT_CLONE == 'false' || env.CACHE_DOWNLOAD_FAILED == 'true')}} + with: + repository: 'cm/cm' + ref: ${{ fromJSON(fromJSON(inputs.client_payload)).cmOrgRef }} + path: gitstream/cm-org/ + + - name: Volume folder shell: bash run: mv gitstream code From 2b61c499d0cd424479049c9c5f19f049350a1e8f Mon Sep 17 00:00:00 2001 From: Yeela Lifshitz Date: Mon, 17 Mar 2025 17:03:17 +0200 Subject: [PATCH 2/4] Refactor checkout conditions in action.yml and update variable handling in get-condition-vars.js --- action.yml | 10 +++++----- scripts/get-condition-vars.js | 9 +++++++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/action.yml b/action.yml index e99d8e2c..941ea56c 100644 --- a/action.yml +++ b/action.yml @@ -89,6 +89,7 @@ runs: IS_NON_COMMIT_ARG: ${{ fromJSON(fromJSON(inputs.client_payload)).isNonCommitEvent }} ENABLE_CACHE_ARG: ${{ env.ENABLE_CACHE }} RUN_ID_ARG: ${{ fromJSON(fromJSON(inputs.client_payload)).artifactRunId }} + CACHE_DOWNLOAD_FAILED_ARG: ${{ env.CACHE_DOWNLOAD_FAILED }} with: script: | require('${{ github.action_path }}/scripts/get-condition-vars.js')(core); @@ -126,7 +127,7 @@ runs: script: require('${{ github.action_path }}/scripts/check-cache-download-status')(core); - name: Checkout Pull Request branches history - if: ${{ env.SKIP_GIT_CLONE == 'false' || env.CACHE_DOWNLOAD_FAILED == 'true' }} + if: ${{ env.SHOULD_CHECKOUT == 'true' }} shell: bash run: | ALL=2147483647 @@ -139,13 +140,13 @@ runs: git checkout $'${{ steps.safe-strings.outputs.head_ref }}' - name: Create cm folder - if: ${{ env.SKIP_GIT_CLONE == 'false' || env.CACHE_DOWNLOAD_FAILED == 'true' }} + if: ${{ env.SHOULD_CHECKOUT == 'true' }} shell: bash run: cd gitstream && mkdir cm - name: Checkout cm repo uses: actions/checkout@v4 - if: ${{ fromJSON(fromJSON(inputs.client_payload)).hasCmRepo == true && (env.SKIP_GIT_CLONE == 'false' || env.CACHE_DOWNLOAD_FAILED == 'true')}} + if: ${{ fromJSON(fromJSON(inputs.client_payload)).hasCmRepo == true && env.SHOULD_CHECKOUT == 'true'}} with: repository: '${{ fromJSON(fromJSON(inputs.client_payload)).owner }}/${{ fromJSON(fromJSON(inputs.client_payload)).cmRepo }}' ref: ${{ fromJSON(fromJSON(inputs.client_payload)).cmRepoRef }} @@ -153,13 +154,12 @@ runs: - name: Checkout cm org uses: actions/checkout@v4 - if: ${{ fromJSON(fromJSON(inputs.client_payload)).hasCmOrg == true && (env.SKIP_GIT_CLONE == 'false' || env.CACHE_DOWNLOAD_FAILED == 'true')}} + if: ${{ fromJSON(fromJSON(inputs.client_payload)).hasCmOrg == true && env.SHOULD_CHECKOUT == 'true'}} with: repository: 'cm/cm' ref: ${{ fromJSON(fromJSON(inputs.client_payload)).cmOrgRef }} path: gitstream/cm-org/ - - name: Volume folder shell: bash run: mv gitstream code diff --git a/scripts/get-condition-vars.js b/scripts/get-condition-vars.js index bb142b51..168b9ce6 100644 --- a/scripts/get-condition-vars.js +++ b/scripts/get-condition-vars.js @@ -1,7 +1,7 @@ /* eslint-disable import/no-commonjs */ module.exports = core => { - const { IS_NON_COMMIT_ARG, ENABLE_CACHE_ARG, RUN_ID_ARG } = process.env + const { IS_NON_COMMIT_ARG, ENABLE_CACHE_ARG, RUN_ID_ARG, CACHE_DOWNLOAD_FAILED } = process.env try { const isRunIdExists = !!RUN_ID_ARG @@ -12,10 +12,15 @@ module.exports = core => { core.exportVariable('IS_NON_COMMIT_EVENT', IS_NON_COMMIT_ARG) core.exportVariable('SKIP_GIT_CLONE', skipGitClone.toString()) + + const shouldCheckout = !skipGitClone || CACHE_DOWNLOAD_FAILED === 'true'; + core.exportVariable('SHOULD_CHECKOUT', shouldCheckout.toString()); + } catch (error) { core.warn(`Failed to get condition variables: ${error.message}`) core.exportVariable('IS_NON_COMMIT_EVENT', 'false') core.exportVariable('SKIP_GIT_CLONE', 'false') + core.exportVariable('SHOULD_CHECKOUT', 'true') } -} +} \ No newline at end of file From 8077e2b86c26618c4631d6b1ac58a9a8a5892d81 Mon Sep 17 00:00:00 2001 From: Yeela Lifshitz Date: Mon, 17 Mar 2025 17:06:32 +0200 Subject: [PATCH 3/4] lint --- scripts/get-condition-vars.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/scripts/get-condition-vars.js b/scripts/get-condition-vars.js index 168b9ce6..cea54638 100644 --- a/scripts/get-condition-vars.js +++ b/scripts/get-condition-vars.js @@ -1,7 +1,12 @@ /* eslint-disable import/no-commonjs */ module.exports = core => { - const { IS_NON_COMMIT_ARG, ENABLE_CACHE_ARG, RUN_ID_ARG, CACHE_DOWNLOAD_FAILED } = process.env + const { + IS_NON_COMMIT_ARG, + ENABLE_CACHE_ARG, + RUN_ID_ARG, + CACHE_DOWNLOAD_FAILED + } = process.env try { const isRunIdExists = !!RUN_ID_ARG @@ -13,9 +18,8 @@ module.exports = core => { core.exportVariable('IS_NON_COMMIT_EVENT', IS_NON_COMMIT_ARG) core.exportVariable('SKIP_GIT_CLONE', skipGitClone.toString()) - const shouldCheckout = !skipGitClone || CACHE_DOWNLOAD_FAILED === 'true'; - core.exportVariable('SHOULD_CHECKOUT', shouldCheckout.toString()); - + const shouldCheckout = !skipGitClone || CACHE_DOWNLOAD_FAILED === 'true' + core.exportVariable('SHOULD_CHECKOUT', shouldCheckout.toString()) } catch (error) { core.warn(`Failed to get condition variables: ${error.message}`) @@ -23,4 +27,4 @@ module.exports = core => { core.exportVariable('SKIP_GIT_CLONE', 'false') core.exportVariable('SHOULD_CHECKOUT', 'true') } -} \ No newline at end of file +} From aaa2647fe71656ecacd9dab1710e344ad2adee40 Mon Sep 17 00:00:00 2001 From: Yeela Lifshitz Date: Mon, 17 Mar 2025 17:56:09 +0200 Subject: [PATCH 4/4] Update path for cm organization in action.yml --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 941ea56c..9e09661e 100644 --- a/action.yml +++ b/action.yml @@ -158,7 +158,7 @@ runs: with: repository: 'cm/cm' ref: ${{ fromJSON(fromJSON(inputs.client_payload)).cmOrgRef }} - path: gitstream/cm-org/ + path: gitstream/cm/ - name: Volume folder shell: bash