diff --git a/action.yml b/action.yml index 5413eb92..9e09661e 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,18 +140,26 @@ 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 }} path: gitstream/cm/ + - name: Checkout cm org + uses: actions/checkout@v4 + 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/ + - 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..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 } = 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 +17,14 @@ 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') } }