I'm saving a JSON field, .body, to an ENV variable. The content of this field will always be changing with multiple strings and characters, it's the body message of a Pull Request in GitHub. So markdown will also get passed:
Below would be an accurate example extracted from .body
#Title
## SubTitle
*date*
1. Item 1
2. Item 2
3. Item 3
When I parse the JSON using jq and -r for its raw content:
echo "PR_BODY=$(jq -r '.body' $HOME/pr.json)" >> $GITHUB_ENV
I get errors from GitHub actions:
For reference, my plan is to save .body data into a markdown file like so after managing to save it to an env variable:
run: |
ed changelog.md <<'END_ED'
1i
${{ env.PR_BODY }}
.
wq
END_ED
echo >> changelog.md
How can I go about extracting the data in .body without empty spaces throwing errors? Perhaps an ENV variable is not the way to go about this?
EDIT: Here is an original raw JSON in the .body:
"body": "Manually configuring ports for DEV, CAT/QA environments. Migrating from managed service to self-serve \"GCP resource\". \r\n\r\n- [x] DEV\r\n- [x] CAT/QA\r\n- [ ] PROD\r\n\r\n```\r\n# Allow healthcheck on ports 80, 443\r\nresource \"google_compute_firewall\" \"allow-healthcheck\" {\r\n name = \"${format(\"%s\",\"${var.gcp_resource_name}-${var.gcp_env}-fw-allow-healthcheck\")}\"\r\n network = \"${google_compute_network.vpc.name}\"\r\n allow {\r\n protocol = \"tcp\"\r\n ports = [\"80\",\"443\"]\r\n }\r\n source_ranges = [\"2.2.0.0/16\", \"1.1.0.0/22\"]\r\n}\r\n```\r\nConfiguring for bug, link here:\r\n[Link To Terraform provider update](https://www.terraform.io/)"
