Skip to content

Commit

Permalink
GHA: Use ENV to escape quotas from json
Browse files Browse the repository at this point in the history
If in JSON are strings, the " need to be escaped, use shell env expansion to automatically escape those characters

Signed-off-by: Robert Gałat <[email protected]>
  • Loading branch information
RobertGalatNordic authored Nov 6, 2023
1 parent 9d1fa9f commit 09fc6f7
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/on-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Print Github context
run:
echo '${{toJson(github)}}'
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"

validate_code_compliance:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -48,8 +49,10 @@ jobs:

- name: get number of commits pushed
id: get_commits
env:
EVENT_COMMITS: ${{toJson(github.event.commits)}
run: |
echo '${{toJson(github.event.commits)}}' > commits.json
echo "$EVENT_COMMITS" > commits.json
tr -d '\n' < commits.json > commits_oneline.json
LL=$( jq '. | length' commits_oneline.json)
echo 'Number of commits pushed: $LL'
Expand Down

0 comments on commit 09fc6f7

Please sign in to comment.