@@ -28,13 +28,25 @@ jobs:
2828 if [ -z "$VERSION" ]; then VERSION="v1.1.0+"; fi
2929 if [ -z "$JJ_VERSION" ]; then JJ_VERSION="0.23.0+"; fi
3030
31- # Create JSON payloads
32- echo "{\"schemaVersion\":1,\"label\":\"Release\",\"message\":\"$VERSION\",\"color\":\"blue\"}" > version.json
33- echo "{\"schemaVersion\":1,\"label\":\"jj\",\"message\":\"$JJ_VERSION\",\"color\":\"purple\"}" > jj.json
31+ # Create JSON content strings
32+ VERSION_JSON= "{\"schemaVersion\":1,\"label\":\"Release\",\"message\":\"$VERSION\",\"color\":\"blue\"}"
33+ JJ_JSON= "{\"schemaVersion\":1,\"label\":\"jj\",\"message\":\"$JJ_VERSION\",\"color\":\"purple\"}"
3434
35- # Update Gist
36- gh gist edit "$GIST_ID" -d "jjConfig Dynamic Badges (Updated: $(date))" version.json
37- # Handle jj.json: use --add equivalent by specifying file mapping
38- gh gist edit "$GIST_ID" --filename jj.json=jj.json
35+ # Construct API payload securely with jq
36+ # We update description and files in one go
37+ jq -n \
38+ --arg desc "jjConfig Dynamic Badges (Updated: $(date))" \
39+ --arg v "$VERSION_JSON" \
40+ --arg j "$JJ_JSON" \
41+ '{description: $desc, files: {"version.json": {content: $v}, "jj.json": {content: $j}}}' > payload.json
42+
43+ # Update Gist via API
44+ curl -L \
45+ -X PATCH \
46+ -H "Accept: application/vnd.github+json" \
47+ -H "Authorization: Bearer $GH_TOKEN" \
48+ -H "X-GitHub-Api-Version: 2022-11-28" \
49+ "https://api.github.com/gists/$GIST_ID" \
50+ -d @payload.json
3951
4052 echo "Updated Gist $GIST_ID with version $VERSION and jj $JJ_VERSION"
0 commit comments