Skip to content

Commit

Permalink
LINBEE-10093 - distinct between org and repo levels on download artif…
Browse files Browse the repository at this point in the history
…act (#121)

* LINBEE-10093 - distinct between org and repo levels when download artifact

* fix

* format

* debug

* debug

* debug

* fix

* core debug

* revert debug core

* debug core

* debug core

* debug core

* remove debugs

* abort debug core version

* dedug core

* abort debug core

---------

Co-authored-by: Yeela Lifshitz <[email protected]>
  • Loading branch information
yeelali14 and Yeela Lifshitz authored Aug 26, 2024
1 parent f65b9fe commit 8330ca1
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
18 changes: 16 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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);

Expand Down Expand Up @@ -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' }}
Expand Down
14 changes: 11 additions & 3 deletions scripts/check-cache-download-status.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
3 changes: 2 additions & 1 deletion scripts/get-condition-vars.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' &&
Expand All @@ -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')
Expand Down

0 comments on commit 8330ca1

Please sign in to comment.