Skip to content

Commit

Permalink
LINBEE-9077 - add the ability to skip clone + download artifact (#108)
Browse files Browse the repository at this point in the history
* LINBEE-9077 - add the ability to skip clone + download artifact

* core 2.1.34-1 debug

* simulate non commit

* core 2.1.34-2 debug

* remove simulation

* core 2.1.34-3

* simulate cache

* remove cache simulation

* revert core debug versions

* format

* ignore naming convention error

* review fixes

* fix to boolean

* fix format

* fix condition

* fix

* simulate cache

* revert simulate cache

---------

Co-authored-by: Yeela Lifshitz <[email protected]>
  • Loading branch information
yeelali14 and Yeela Lifshitz authored Aug 15, 2024
1 parent c48b62c commit d705a71
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
34 changes: 33 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,27 @@ runs:
process.exit(1);
}
- name: Get condition variables
uses: actions/github-script@v7
env:
CLIENT_PAYLOAD_ARG: ${{ inputs.client_payload }}
ENABLE_CACHE_ARG: ${{ env.ENABLE_CACHE }}
with:
script: |
require('${{ github.action_path }}/scripts/get-condition-vars.js')(core);
- name: Download cache artifact
uses: actions/download-artifact@v4
if: ${{ env.SKIP_GIT_CLONE == '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: Checkout Pull Request branches history
if: ${{ env.SKIP_GIT_CLONE == 'false' }}
shell: bash
run: |
ALL=2147483647
Expand All @@ -96,12 +116,13 @@ runs:
git checkout $'${{ steps.safe-strings.outputs.head_ref }}'
- name: Create cm folder
if: ${{ env.SKIP_GIT_CLONE == 'false' }}
shell: bash
run: cd gitstream && mkdir cm

- name: Checkout cm repo
uses: actions/checkout@v4
if: ${{ fromJSON(fromJSON(inputs.client_payload)).hasCmRepo == true }}
if: ${{ fromJSON(fromJSON(inputs.client_payload)).hasCmRepo == true && env.SKIP_GIT_CLONE == 'false' }}
with:
repository: '${{ fromJSON(fromJSON(inputs.client_payload)).owner }}/${{ fromJSON(fromJSON(inputs.client_payload)).cmRepo }}'
ref: ${{ fromJSON(fromJSON(inputs.client_payload)).cmRepoRef }}
Expand All @@ -125,3 +146,14 @@ runs:
RULES_RESOLVER_URL: ${{ inputs.resolver_url }}
RULES_RESOLVER_TOKEN: ${{ inputs.resolver_token }}
DEBUG_MODE: ${{ inputs.debug_mode }}
IS_NON_COMMIT_EVENT: ${{ env.IS_NON_COMMIT_EVENT }}
ENABLE_CACHE: ${{ env.ENABLE_CACHE || 'false' }}
ENABLE_DEBUG_ARTIFACTS: ${{ env.ENABLE_DEBUG_ARTIFACTS }}

- name: Upload artifacts
if: ${{ env.ENABLE_DEBUG_ARTIFACTS == 'true' || env.ENABLE_CACHE == 'true' }}
uses: actions/upload-artifact@v4
with:
retention-days: 2
name: output
path: code/output
16 changes: 16 additions & 0 deletions scripts/get-condition-vars.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* eslint-disable import/no-commonjs */

module.exports = core => {
const { CLIENT_PAYLOAD_ARG, ENABLE_CACHE_ARG } = process.env
try {
const payload = JSON.parse(CLIENT_PAYLOAD_ARG)
const isNonCommitEvent = payload.isNonCommitEvent === true
const skipGitClone = isNonCommitEvent && ENABLE_CACHE_ARG === 'true'
core.exportVariable('IS_NON_COMMIT_EVENT', isNonCommitEvent.toString())
core.exportVariable('SKIP_GIT_CLONE', skipGitClone.toString())
} catch (error) {
core.setFailed(error.message)
core.exportVariable('IS_NON_COMMIT_EVENT', 'false')
core.exportVariable('SKIP_GIT_CLONE', 'false')
}
}

0 comments on commit d705a71

Please sign in to comment.