diff --git a/action.yml b/action.yml index c19c107c..5413eb92 100644 --- a/action.yml +++ b/action.yml @@ -93,10 +93,22 @@ runs: script: | require('${{ github.action_path }}/scripts/get-condition-vars.js')(core); - - name: Download cache artifact + - name: Download cache artifact for cm repo + id: download-cache-for-cm-repo + uses: actions/download-artifact@v4 + if: ${{ env.SKIP_GIT_CLONE == 'true' && fromJSON(fromJSON(inputs.client_payload)).hasCmRepo == true }} + continue-on-error: true + with: + github-token: ${{ fromJSON(fromJSON(inputs.client_payload)).githubToken || github.token }} + repository: '${{ fromJSON(fromJSON(inputs.client_payload)).owner }}/${{ fromJSON(fromJSON(inputs.client_payload)).cmRepo }}' + run-id: ${{ fromJSON(fromJSON(inputs.client_payload)).artifactRunId }} + name: output + path: code/output + + - name: Download cache artifact when cmRepo is false id: download-cache uses: actions/download-artifact@v4 - if: ${{ env.SKIP_GIT_CLONE == 'true' }} + if: ${{ env.SKIP_GIT_CLONE == 'true' && fromJSON(fromJSON(inputs.client_payload)).hasCmRepo == false}} continue-on-error: true with: github-token: ${{ fromJSON(fromJSON(inputs.client_payload)).githubToken || github.token }} @@ -109,6 +121,7 @@ runs: uses: actions/github-script@v7 env: ARTIFACT_OUTCOME_ARG: ${{ steps.download-cache.outcome }} + ARTIFACT_OUTCOME_CM_REPO_ARG: ${{ steps.download-cache-for-cm-repo.outcome }} with: script: require('${{ github.action_path }}/scripts/check-cache-download-status')(core); @@ -159,6 +172,7 @@ runs: SHOULD_SKIP_CLONE: ${{ env.SKIP_GIT_CLONE == 'true' && env.CACHE_DOWNLOAD_FAILED == 'false'}} ENABLE_CACHE: ${{ env.ENABLE_CACHE }} ENABLE_DEBUG_ARTIFACTS: ${{ env.ENABLE_DEBUG_ARTIFACTS }} + RUN_ID: ${{ github.run_id }} - name: Upload artifacts if: ${{ env.ENABLE_DEBUG_ARTIFACTS == 'true' || env.ENABLE_CACHE == 'true' }} diff --git a/scripts/check-cache-download-status.js b/scripts/check-cache-download-status.js index 914c6f6f..0a3cdd09 100644 --- a/scripts/check-cache-download-status.js +++ b/scripts/check-cache-download-status.js @@ -2,10 +2,18 @@ module.exports = core => { try { - const { ARTIFACT_OUTCOME_ARG } = process.env - core.info(`Setting cache download status to: ${ARTIFACT_OUTCOME_ARG}`) + const { ARTIFACT_OUTCOME_ARG, ARTIFACT_OUTCOME_CM_REPO_ARG } = process.env + core.info( + `ARTIFACT_OUTCOME_ARG Cache download status: ${ARTIFACT_OUTCOME_ARG}.` + ) + core.info( + `ARTIFACT_OUTCOME_CM_REPO_ARG Cache download status: ${ARTIFACT_OUTCOME_CM_REPO_ARG}.` + ) - if (ARTIFACT_OUTCOME_ARG === 'failure') { + if ( + ARTIFACT_OUTCOME_ARG === 'failure' || + ARTIFACT_OUTCOME_CM_REPO_ARG === 'failure' + ) { core.exportVariable('CACHE_DOWNLOAD_FAILED', 'true') } else { core.exportVariable('CACHE_DOWNLOAD_FAILED', 'false') diff --git a/scripts/get-condition-vars.js b/scripts/get-condition-vars.js index fae53ad0..bb142b51 100644 --- a/scripts/get-condition-vars.js +++ b/scripts/get-condition-vars.js @@ -4,6 +4,7 @@ module.exports = core => { const { IS_NON_COMMIT_ARG, ENABLE_CACHE_ARG, RUN_ID_ARG } = process.env try { const isRunIdExists = !!RUN_ID_ARG + const skipGitClone = IS_NON_COMMIT_ARG === 'true' && ENABLE_CACHE_ARG === 'true' && @@ -12,7 +13,7 @@ module.exports = core => { core.exportVariable('IS_NON_COMMIT_EVENT', IS_NON_COMMIT_ARG) core.exportVariable('SKIP_GIT_CLONE', skipGitClone.toString()) } catch (error) { - core.warn(error.message) + core.warn(`Failed to get condition variables: ${error.message}`) core.exportVariable('IS_NON_COMMIT_EVENT', 'false') core.exportVariable('SKIP_GIT_CLONE', 'false')