Skip to content

Commit

Permalink
BC-5468 add error reading in json file
Browse files Browse the repository at this point in the history
  • Loading branch information
UzaeirKhan committed Nov 14, 2023
1 parent ed8d482 commit aa8f43e
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,21 @@ jobs:
file_paths+=("$file_path")
while IFS="=" read -r key value; do
key_value_pairs["$key"]=$value
done < <(jq -r 'to_entries | map("\(.key)=\(.value|tostring)") | .[]' "$file_path")
result=$(jq -c . < "$file_path")
if [ $? -eq 0 ]; then
key_value_pairs+=($(jq -c '. | to_entries | .[]' < "$file_path"))
else
echo "Error reading JSON file: $file_path"
cat "$file_path"
exit 1
fi
# while IFS="=" read -r key value; do
# key_value_pairs["$key"]=$value
# done < <(jq -r 'to_entries | .[] | "\(.key)=\(.value)"' "$file_path")
done
json_output=$(declare -p key_value_pairs | jq -r 'from_entries')
json_output=$(jq -n -c 'reduce inputs as $item ({}; . * $item)')
# json_output="{"
# for key in "${!key_value_pairs[@]}"; do
Expand All @@ -117,7 +122,15 @@ jobs:
# json_output="${json_output%,}"
# json_output+="}"
echo "$json_output" > ${{ github.workspace }}/e2e-system-tests/env_variables/combined_credentials.json
if [ $? -eq 0 ]; then
# Write JSON output to file if successful
echo "$json_output" > "${{ github.workspace }}/e2e-system-tests/env_variables/combined_credentials.json"
else
echo "Error occurred during JSON concatenation."
# Print the merged JSON content
echo "$json_output"
exit 1
fi
- name: Clean up previous report
uses: cypress-io/github-action@v5
Expand Down

0 comments on commit aa8f43e

Please sign in to comment.