Skip to content

Commit 4682c49

Browse files
yeelali14Yeela Lifshitz
andauthored
LINBEE-14851 - Add checkout step for CM organization in action.yml (#260)
* Add checkout step for cm organization in action.yml * Refactor checkout conditions in action.yml and update variable handling in get-condition-vars.js * lint * Update path for cm organization in action.yml --------- Co-authored-by: Yeela Lifshitz <yeelalifshitz@Yeela-MacBook-Pro.local>
1 parent 37572df commit 4682c49

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

action.yml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ runs:
8989
IS_NON_COMMIT_ARG: ${{ fromJSON(fromJSON(inputs.client_payload)).isNonCommitEvent }}
9090
ENABLE_CACHE_ARG: ${{ env.ENABLE_CACHE }}
9191
RUN_ID_ARG: ${{ fromJSON(fromJSON(inputs.client_payload)).artifactRunId }}
92+
CACHE_DOWNLOAD_FAILED_ARG: ${{ env.CACHE_DOWNLOAD_FAILED }}
9293
with:
9394
script: |
9495
require('${{ github.action_path }}/scripts/get-condition-vars.js')(core);
@@ -126,7 +127,7 @@ runs:
126127
script: require('${{ github.action_path }}/scripts/check-cache-download-status')(core);
127128

128129
- name: Checkout Pull Request branches history
129-
if: ${{ env.SKIP_GIT_CLONE == 'false' || env.CACHE_DOWNLOAD_FAILED == 'true' }}
130+
if: ${{ env.SHOULD_CHECKOUT == 'true' }}
130131
shell: bash
131132
run: |
132133
ALL=2147483647
@@ -139,18 +140,26 @@ runs:
139140
git checkout $'${{ steps.safe-strings.outputs.head_ref }}'
140141
141142
- name: Create cm folder
142-
if: ${{ env.SKIP_GIT_CLONE == 'false' || env.CACHE_DOWNLOAD_FAILED == 'true' }}
143+
if: ${{ env.SHOULD_CHECKOUT == 'true' }}
143144
shell: bash
144145
run: cd gitstream && mkdir cm
145146

146147
- name: Checkout cm repo
147148
uses: actions/checkout@v4
148-
if: ${{ fromJSON(fromJSON(inputs.client_payload)).hasCmRepo == true && (env.SKIP_GIT_CLONE == 'false' || env.CACHE_DOWNLOAD_FAILED == 'true')}}
149+
if: ${{ fromJSON(fromJSON(inputs.client_payload)).hasCmRepo == true && env.SHOULD_CHECKOUT == 'true'}}
149150
with:
150151
repository: '${{ fromJSON(fromJSON(inputs.client_payload)).owner }}/${{ fromJSON(fromJSON(inputs.client_payload)).cmRepo }}'
151152
ref: ${{ fromJSON(fromJSON(inputs.client_payload)).cmRepoRef }}
152153
path: gitstream/cm/
153154

155+
- name: Checkout cm org
156+
uses: actions/checkout@v4
157+
if: ${{ fromJSON(fromJSON(inputs.client_payload)).hasCmOrg == true && env.SHOULD_CHECKOUT == 'true'}}
158+
with:
159+
repository: 'cm/cm'
160+
ref: ${{ fromJSON(fromJSON(inputs.client_payload)).cmOrgRef }}
161+
path: gitstream/cm/
162+
154163
- name: Volume folder
155164
shell: bash
156165
run: mv gitstream code

scripts/get-condition-vars.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
/* eslint-disable import/no-commonjs */
22

33
module.exports = core => {
4-
const { IS_NON_COMMIT_ARG, ENABLE_CACHE_ARG, RUN_ID_ARG } = process.env
4+
const {
5+
IS_NON_COMMIT_ARG,
6+
ENABLE_CACHE_ARG,
7+
RUN_ID_ARG,
8+
CACHE_DOWNLOAD_FAILED
9+
} = process.env
510
try {
611
const isRunIdExists = !!RUN_ID_ARG
712

@@ -12,10 +17,14 @@ module.exports = core => {
1217

1318
core.exportVariable('IS_NON_COMMIT_EVENT', IS_NON_COMMIT_ARG)
1419
core.exportVariable('SKIP_GIT_CLONE', skipGitClone.toString())
20+
21+
const shouldCheckout = !skipGitClone || CACHE_DOWNLOAD_FAILED === 'true'
22+
core.exportVariable('SHOULD_CHECKOUT', shouldCheckout.toString())
1523
} catch (error) {
1624
core.warn(`Failed to get condition variables: ${error.message}`)
1725

1826
core.exportVariable('IS_NON_COMMIT_EVENT', 'false')
1927
core.exportVariable('SKIP_GIT_CLONE', 'false')
28+
core.exportVariable('SHOULD_CHECKOUT', 'true')
2029
}
2130
}

0 commit comments

Comments
 (0)