Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
11 changes: 10 additions & 1 deletion scripts/get-condition-vars.js
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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')
}
}