File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -92,12 +92,16 @@ jobs:
9292 continue
9393 fi
9494
95+ # Build JSON payloads with jq to handle special characters
96+ PATCH_BODY=$(jq -n --arg v "$VALUE" '{value: $v}')
97+ POST_BODY=$(jq -n --arg n "$VAR_NAME" --arg v "$VALUE" '{name: $n, value: $v}')
98+
9599 # Try update first (PATCH), fall back to create (POST)
96100 HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" -X PATCH \
97101 "https://api.github.com/repos/${REPO}/actions/variables/${VAR_NAME}" \
98102 -H "Authorization: Bearer ${GH_TOKEN}" \
99103 -H "Accept: application/vnd.github+json" \
100- -d "{\"value\":\"${VALUE}\"} ")
104+ -d "$PATCH_BODY ")
101105
102106 if [ "$HTTP_CODE" = "204" ]; then
103107 echo "UPDATED: $VAR_NAME"
@@ -107,7 +111,7 @@ jobs:
107111 "https://api.github.com/repos/${REPO}/actions/variables" \
108112 -H "Authorization: Bearer ${GH_TOKEN}" \
109113 -H "Accept: application/vnd.github+json" \
110- -d "{\"name\":\"${VAR_NAME}\",\"value\":\"${VALUE}\"} ")
114+ -d "$POST_BODY ")
111115
112116 if [ "$HTTP_CODE" = "201" ]; then
113117 echo "CREATED: $VAR_NAME"
You can’t perform that action at this time.
0 commit comments