Skip to content

Commit

Permalink
Merge pull request #50 from linear-b/LINBEE-2919
Browse files Browse the repository at this point in the history
LINBEE-2919 - add try catch to finish github check propely
  • Loading branch information
yeelali14 authored Sep 28, 2023
2 parents 76e63a2 + 918aab5 commit be07162
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,12 @@ runs:
mkdir gitstream
cd gitstream
mkdir repo
- name: Cache gitstream results
id: cache-gitstream-results
uses: actions/cache@v3
with:
path: gitstream/cache.json
key: ${{ fromJSON(fromJSON(github.event.inputs.client_payload)).headSha }}-gitstream-cache

- name: Checkout base branch
uses: actions/checkout@v3
if: ${{ steps.cache-gitstream-results.outputs.cache-hit != 'true' }}
Expand All @@ -56,32 +54,35 @@ runs:
ref: ${{ github.event.inputs.base_ref }}
path: 'gitstream/repo/'
token: ${{ fromJSON(fromJSON(github.event.inputs.client_payload)).githubToken || github.token }}

- name: Escape single quotes
id: safe-strings
uses: actions/github-script@v3
env:
BASE_REF_ARG: ${{ github.event.inputs.base_ref }}
HEAD_REF_ARG: ${{ github.event.inputs.head_ref }}
PAYLOAD_ARG: ${{ github.event.inputs.client_payload }}
URL_ARG: ${{ fromJSON(fromJSON(github.event.inputs.client_payload)).headHttpUrl || fromJSON(fromJSON(github.event.inputs.client_payload)).repoUrl }}
with:
base_ref_arg: ${{ github.event.inputs.base_ref }}
head_ref_arg: ${{ github.event.inputs.head_ref }}
payload_arg: ${{ github.event.inputs.client_payload }}
url_arg: ${{ fromJSON(fromJSON(github.event.inputs.client_payload)).headHttpUrl || fromJSON(fromJSON(github.event.inputs.client_payload)).repoUrl }}
script: |
function convertToSafeString(input) {
return (input || '').replace(/['`]/g, "\\$&");
};
function escapeApostrophe(input) {
return (input || '').replace(/'/g, "\\'");
};
const base_ref = escapeApostrophe(core.getInput('base_ref_arg'));
const head_ref = escapeApostrophe(core.getInput('head_ref_arg'));
const url = convertToSafeString(core.getInput('url_arg'));
const client_payload = convertToSafeString(core.getInput('payload_arg'));
core.setOutput('base_ref', base_ref);
core.setOutput('head_ref', head_ref);
core.setOutput('url', url);
core.setOutput('client_payload', client_payload);
try {
function convertToSafeString(input) {
return (input || '').replace(/['`]/g, "\\$&");
};
function escapeApostrophe(input) {
return (input || '').replace(/'/g, "\\'");
};
const base_ref = escapeApostrophe(process.env.BASE_REF_ARG);
const head_ref = escapeApostrophe(process.env.HEAD_REF_ARG);
const url = convertToSafeString(process.env.URL_ARG);
const client_payload = convertToSafeString(process.env.PAYLOAD_ARG);
core.setOutput('base_ref', base_ref);
core.setOutput('head_ref', head_ref);
core.setOutput('url', url);
core.setOutput('client_payload', client_payload);
} catch (err) {
core.error(`Failed producing safe string: ${err}`);
process.exit(1);
}
- if: ${{ steps.cache-gitstream-results.outputs.cache-hit != 'true' }}
run: |
all=2147483647
Expand All @@ -92,7 +93,6 @@ runs:
git fetch --deepen=$all upstream $'${{ steps.safe-strings.outputs.head_ref }}'
git checkout -b $'upstream/${{ steps.safe-strings.outputs.head_ref}}' $'upstream/${{ steps.safe-strings.outputs.head_ref}}'
shell: bash

- name: Create cm folder
id: create-cm-folder
shell: bash
Expand Down Expand Up @@ -123,4 +123,4 @@ runs:
docker run --env-file $env_file -v $(pwd)/gitstream:/code -e USE_CACHE=${{ steps.cache-gitstream-results.outputs.cache-hit }} -e HEAD_REF=$'upstream/${{ steps.safe-strings.outputs.head_ref }}' -e BASE_REF=$'${{ steps.safe-strings.outputs.base_ref }}' -e CLIENT_PAYLOAD=${{ steps.safe-strings.outputs.client_payload }} -e RULES_RESOLVER_URL=${{ github.event.inputs.resolver_url }} -e RULES_RESOLVER_TOKEN=${{ github.event.inputs.resolver_token }} -e DEBUG_MODE=${{ github.event.inputs.debug_mode }} gitstream/rules-engine
echo "docker-run-duration=$SECONDS" >> $GITHUB_OUTPUT
echo "action-run-duration=$(($EPOCHSECONDS - ${{ steps.start.outputs.timestamp }}))" >> $GITHUB_OUTPUT
shell: bash
shell: bash

0 comments on commit be07162

Please sign in to comment.