Skip to content

Commit

Permalink
BC-5468 update yml with new script
Browse files Browse the repository at this point in the history
  • Loading branch information
UzaeirKhan committed Nov 14, 2023
1 parent f154466 commit baa919f
Showing 1 changed file with 45 additions and 23 deletions.
68 changes: 45 additions & 23 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,36 +87,58 @@ jobs:
environment="dev"
fi
file_paths=()
declare -A key_value_pairs
declare -A key_value_pairs=()
for instance in "${instances[@]}"; do
if [[ $workflow_name == *"manual"* || $workflow_name == *"remote"* ]]; then
file_path="${{ github.workspace }}/e2e-system-tests/env_variables/file-${environment}-${instance}.json"
else
file_path="${{ github.workspace }}/e2e-system-tests/env_variables/file-dev-${instance}.json"
fi
retrieve_environment_variables() {
local instance="$1"
local file_path
file_paths+=("$file_path")
if [[ $workflow_name == *"manual"* || $workflow_name == *"remote"* ]]; then
file_path="${{ github.workspace }}/e2e-system-tests/env_variables/file-${environment}-${instance}.json"
else
file_path="${{ github.workspace }}/e2e-system-tests/env_variables/file-dev-${instance}.json"
fi
while IFS="=" read -r key value; do
key_value_pairs["$key"]=$value
done < <(jq -r 'to_entries | .[] | "\(.key)=\(.value)"' "$file_path")
done
while IFS="=" read -r key value; do
key_value_pairs["$key"]=$value
done < <(jq -r 'to_entries | .[] | "\(.key)=\(.value)"' "$file_path")
}
generate_combined_credentials() {
declare -p key_value_pairs | jq -r 'map_values(tostring) | to_entries | map("\(.key): \(.value)") | "{" + join(", ") + "}"' >"${{ github.workspace }}/e2e-system-tests/env_variables/combined_credentials.json"
}
json_output="{"
for key in "${!key_value_pairs[@]}"; do
json_output+="\"$key\":\"${key_value_pairs[$key]}\","
for instance in "${instances[@]}"; do
retrieve_environment_variables "$instance"
done
json_output="${json_output%,}"
json_output+="}"
echo "$json_output" > ${{ github.workspace }}/e2e-system-tests/env_variables/combined_credentials.json
generate_combined_credentials
# file_paths=()
# declare -A key_value_pairs
# for instance in "${instances[@]}"; do
# if [[ $workflow_name == *"manual"* || $workflow_name == *"remote"* ]]; then
# file_path="${{ github.workspace }}/e2e-system-tests/env_variables/file-${environment}-${instance}.json"
# else
# file_path="${{ github.workspace }}/e2e-system-tests/env_variables/file-dev-${instance}.json"
# fi
# file_paths+=("$file_path")
# while IFS="=" read -r key value; do
# key_value_pairs["$key"]=$value
# done < <(jq -r 'to_entries | .[] | "\(.key)=\(.value)"' "$file_path")
# done
# json_output="{"
# for key in "${!key_value_pairs[@]}"; do
# json_output+="\"$key\":\"${key_value_pairs[$key]}\","
# done
# json_output="${json_output%,}"
# json_output+="}"
# while IFS="=" read -r key value; do
# echo "Setting $key"
# echo "$key=$value" >> $GITHUB_ENV
# done < <(jq -r 'to_entries | .[] | .key + "=" + .value' "${{ github.workspace }}/e2e-system-tests/env_variables/combined_credentials.json")
# echo "$json_output" > ${{ github.workspace }}/e2e-system-tests/env_variables/combined_credentials.json
- name: Clean up previous report
uses: cypress-io/github-action@v5
Expand Down

0 comments on commit baa919f

Please sign in to comment.