diff --git a/action.yml b/action.yml index d151f1f6..c690ffb9 100644 --- a/action.yml +++ b/action.yml @@ -79,51 +79,7 @@ runs: process.exit(1); } - - name: Get condition variables - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 - env: - 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); - - - name: Download cache artifact for cm repo - id: download-cache-for-cm-repo - uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0 - 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@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0 - 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 }} - repository: ${{ inputs.full_repository }} - run-id: ${{ fromJSON(fromJSON(inputs.client_payload)).artifactRunId }} - name: output - path: code/output - - - name: Check if download cache artifact failed - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 - 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); - - name: Checkout Pull Request branches history - if: ${{ env.SHOULD_CHECKOUT == 'true' }} shell: bash run: | cd gitstream && cd repo @@ -136,13 +92,12 @@ runs: git checkout $'${{ steps.safe-strings.outputs.head_ref }}' - name: Create cm folder - if: ${{ env.SHOULD_CHECKOUT == 'true' }} shell: bash run: cd gitstream && mkdir cm - name: Checkout cm repo uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - if: ${{ fromJSON(fromJSON(inputs.client_payload)).hasCmRepo == true && env.SHOULD_CHECKOUT == 'true'}} + if: ${{ fromJSON(fromJSON(inputs.client_payload)).hasCmRepo == true }} with: repository: '${{ fromJSON(fromJSON(inputs.client_payload)).owner }}/${{ fromJSON(fromJSON(inputs.client_payload)).cmRepo }}' ref: ${{ fromJSON(fromJSON(inputs.client_payload)).cmRepoRef }} @@ -151,7 +106,7 @@ runs: - name: Checkout cm org uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - if: ${{ fromJSON(fromJSON(inputs.client_payload)).hasCmOrg == true && env.SHOULD_CHECKOUT == 'true'}} + if: ${{ fromJSON(fromJSON(inputs.client_payload)).hasCmOrg == true }} with: repository: 'cm/cm' ref: ${{ fromJSON(fromJSON(inputs.client_payload)).cmOrgRef }} @@ -177,13 +132,11 @@ runs: RULES_RESOLVER_URL: ${{ inputs.resolver_url }} RULES_RESOLVER_TOKEN: ${{ inputs.resolver_token }} DEBUG_MODE: ${{ inputs.debug_mode }} - 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' }} + if: ${{ env.ENABLE_DEBUG_ARTIFACTS == 'true' }} uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0 with: retention-days: 7 diff --git a/scripts/check-cache-download-status.js b/scripts/check-cache-download-status.js deleted file mode 100644 index a207bf01..00000000 --- a/scripts/check-cache-download-status.js +++ /dev/null @@ -1,23 +0,0 @@ -module.exports = core => { - try { - 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' || - ARTIFACT_OUTCOME_CM_REPO_ARG === 'failure' - ) { - core.exportVariable('CACHE_DOWNLOAD_FAILED', 'true') - } else { - core.exportVariable('CACHE_DOWNLOAD_FAILED', 'false') - } - } catch (error) { - core.warn(`Failed to set cache download status: ${error.message}`) - core.exportVariable('CACHE_DOWNLOAD_FAILED', 'true') - } -} diff --git a/scripts/get-condition-vars.js b/scripts/get-condition-vars.js deleted file mode 100644 index f7504457..00000000 --- a/scripts/get-condition-vars.js +++ /dev/null @@ -1,28 +0,0 @@ -module.exports = core => { - const { - IS_NON_COMMIT_ARG, - ENABLE_CACHE_ARG, - RUN_ID_ARG, - CACHE_DOWNLOAD_FAILED - } = process.env - try { - const isRunIdExists = !!RUN_ID_ARG - - const skipGitClone = - IS_NON_COMMIT_ARG === 'true' && - ENABLE_CACHE_ARG === 'true' && - isRunIdExists - - 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') - } -}