Skip to content

Commit 2df83c8

Browse files
Thomo1318Thomo1318
authored andcommitted
fix: switch dynamic badge update to GitHub API
1 parent 58f74b4 commit 2df83c8

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

.github/workflows/dynamic-badges.yml

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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"

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
[![Version](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/Thomo1318/e766526dd2d577b808dc24e114e1cd0b/raw/version.json)](https://github.com/Thomo1318/jjConfig/releases)
66
[![GitGuardian](https://img.shields.io/github/actions/workflow/status/Thomo1318/jjConfig/ggshield.yml?label=Security&logo=gitguardian)](https://github.com/Thomo1318/jjConfig/actions/workflows/ggshield.yml)
77
![CodeRabbit Badge](https://img.shields.io/badge/CodeRabbit-FF570A?logo=coderabbit&logoColor=fff&style=flat)
8-
98
[![Docs](https://img.shields.io/github/actions/workflow/status/Thomo1318/jjConfig/ci-docs.yml?label=Docs&logo=materialformkdocs)](https://github.com/Thomo1318/jjConfig/actions/workflows/ci-docs.yml)
109
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)
1110
[![Jujutsu](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/Thomo1318/e766526dd2d577b808dc24e114e1cd0b/raw/jj.json)](https://github.com/jj-vcs/jj)

0 commit comments

Comments
 (0)