Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LINBEE-2573 | handle quotes in GitHub #48

Merged
merged 16 commits into from
Sep 10, 2023
Merged
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
29 changes: 24 additions & 5 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,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: escape-quotes
uses: actions/github-script@v3
with:
base_ref_arg: ${{ github.event.inputs.base_ref }}
head_ref_arg: ${{ github.event.inputs.head_ref }}
url_arg: ${{ fromJSON(fromJSON(github.event.inputs.client_payload)).headHttpUrl || fromJSON(fromJSON(github.event.inputs.client_payload)).repoUrl }}
script: |
function escapeSingleQuoteChars(input) {
return (input || '').replace(/'/g, "\\'");
};
const base_ref = escapeSingleQuoteChars(core.getInput('base_ref_arg'));
const head_ref = escapeSingleQuoteChars(core.getInput('head_ref_arg'));
const url = escapeSingleQuoteChars(core.getInput('url_arg'));
core.setOutput('base_ref', base_ref);
core.setOutput('head_ref', head_ref);
core.setOutput('url', url);
- if: ${{ steps.cache-gitstream-results.outputs.cache-hit != 'true' }}
run: |
all=2147483647
cd gitstream
cd repo
git fetch --deepen=$all origin ${{ github.event.inputs.base_ref }}
git remote add upstream ${{ fromJSON(fromJSON(github.event.inputs.client_payload)).headHttpUrl || fromJSON(fromJSON(github.event.inputs.client_payload)).repoUrl }}
git fetch --deepen=$all upstream ${{ github.event.inputs.head_ref }}
git checkout -b upstream/${{ github.event.inputs.head_ref }} upstream/${{ github.event.inputs.head_ref }}
git fetch --deepen=$all origin $'${{ steps.escape-quotes.outputs.base_ref }}'
git remote add upstream $'${{ steps.escape-quotes.outputs.url }}'
git fetch --deepen=$all upstream $'${{ steps.escape-quotes.outputs.head_ref }}'
git checkout -b $'upstream/${{ steps.escape-quotes.outputs.head_ref}}' $'upstream/${{ steps.escape-quotes.outputs.head_ref}}'
shell: bash

- name: Create cm folder
id: create-cm-folder
shell: bash
Expand Down Expand Up @@ -93,7 +112,7 @@ runs:
docker pull gitstream/rules-engine:latest
echo "docker-pull-duration=$SECONDS" >> $GITHUB_OUTPUT
SECONDS=0
docker run --env-file $env_file -v $(pwd)/gitstream:/code -e USE_CACHE=${{ steps.cache-gitstream-results.outputs.cache-hit }} -e HEAD_REF=upstream/${{ github.event.inputs.head_ref }} -e BASE_REF=${{ github.event.inputs.base_ref }} -e CLIENT_PAYLOAD=${{ github.event.inputs.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
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.escape-quotes.outputs.head_ref }}' -e BASE_REF=$'${{ steps.escape-quotes.outputs.base_ref }}' -e CLIENT_PAYLOAD=${{ github.event.inputs.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