ci: migrate coverage badge to Gitea Packages
Replace commit-based badge update with a single PUT to the Gitea generic packages API. Removes the badges/ directory from the repo and eliminates CI commits on every push. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
90e3b65820
commit
e6180b57c3
32
.drone.yml
32
.drone.yml
@ -31,35 +31,11 @@ steps:
|
|||||||
else FILL="#e05d44"; fi
|
else FILL="#e05d44"; fi
|
||||||
echo "PCT=$PCT FILL=$FILL"
|
echo "PCT=$PCT FILL=$FILL"
|
||||||
printf '<svg xmlns="http://www.w3.org/2000/svg" width="120" height="20"><rect width="76" height="20" fill="#555"/><rect x="76" width="44" height="20" fill="%s"/><g fill="#fff" text-anchor="middle" font-family="sans-serif" font-size="11"><text x="38" y="14">coverage</text><text x="98" y="14">%s%%</text></g></svg>' "$FILL" "$PCT" > coverage.svg
|
printf '<svg xmlns="http://www.w3.org/2000/svg" width="120" height="20"><rect width="76" height="20" fill="#555"/><rect x="76" width="44" height="20" fill="%s"/><g fill="#fff" text-anchor="middle" font-family="sans-serif" font-size="11"><text x="38" y="14">coverage</text><text x="98" y="14">%s%%</text></g></svg>' "$FILL" "$PCT" > coverage.svg
|
||||||
CONTENT=$(base64 coverage.svg | tr -d '\n')
|
curl -fsSL -X PUT \
|
||||||
echo "Content length: ${#CONTENT}"
|
|
||||||
SHA_RESP=$(curl -s \
|
|
||||||
-H "Authorization: token $GITEA_TOKEN" \
|
-H "Authorization: token $GITEA_TOKEN" \
|
||||||
"https://git.cincoeuzebio.com/api/v1/repos/cinco/Tmuxido/contents/badges/coverage.svg?ref=main")
|
-H "Content-Type: image/svg+xml" \
|
||||||
echo "SHA response: $SHA_RESP"
|
--data-binary @coverage.svg \
|
||||||
SHA=$(echo "$SHA_RESP" | jq -r '.sha // empty')
|
"https://git.cincoeuzebio.com/api/packages/cinco/generic/badges/latest/coverage.svg"
|
||||||
echo "SHA: '$SHA'"
|
|
||||||
if [ -n "$SHA" ]; then
|
|
||||||
PAYLOAD=$(jq -n --arg msg "ci: update coverage badge [CI SKIP]" \
|
|
||||||
--arg content "$CONTENT" --arg sha "$SHA" --arg branch "main" \
|
|
||||||
'{message: $msg, content: $content, sha: $sha, branch: $branch}')
|
|
||||||
RESPONSE=$(curl -s -X PUT \
|
|
||||||
-H "Authorization: token $GITEA_TOKEN" \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
"https://git.cincoeuzebio.com/api/v1/repos/cinco/Tmuxido/contents/badges/coverage.svg" \
|
|
||||||
-d "$PAYLOAD")
|
|
||||||
else
|
|
||||||
PAYLOAD=$(jq -n --arg msg "ci: add coverage badge [CI SKIP]" \
|
|
||||||
--arg content "$CONTENT" --arg branch "main" \
|
|
||||||
'{message: $msg, content: $content, branch: $branch}')
|
|
||||||
RESPONSE=$(curl -s -X POST \
|
|
||||||
-H "Authorization: token $GITEA_TOKEN" \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
"https://git.cincoeuzebio.com/api/v1/repos/cinco/Tmuxido/contents/badges/coverage.svg" \
|
|
||||||
-d "$PAYLOAD")
|
|
||||||
fi
|
|
||||||
echo "API response: $RESPONSE"
|
|
||||||
echo "$RESPONSE" | tr -d '\n' | jq -e '.content.sha' > /dev/null
|
|
||||||
|
|
||||||
---
|
---
|
||||||
kind: pipeline
|
kind: pipeline
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
# tmuxido
|
# tmuxido
|
||||||
|
|
||||||
[](https://drone.cincoeuzebio.com/cinco/Tmuxido)
|
[](https://drone.cincoeuzebio.com/cinco/Tmuxido)
|
||||||
[](https://drone.cincoeuzebio.com/cinco/Tmuxido)
|
[](https://drone.cincoeuzebio.com/cinco/Tmuxido)
|
||||||
[](https://git.cincoeuzebio.com/cinco/Tmuxido/releases)
|
[](https://git.cincoeuzebio.com/cinco/Tmuxido/releases)
|
||||||

|

|
||||||
|
|
||||||
|
|||||||
@ -1 +0,0 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" width="120" height="20"><rect width="76" height="20" fill="#555"/><rect x="76" width="44" height="20" fill="#e05d44"/><g fill="#fff" text-anchor="middle" font-family="sans-serif" font-size="11"><text x="38" y="14">coverage</text><text x="98" y="14">35%</text></g></svg>
|
|
||||||
|
Before Width: | Height: | Size: 309 B |
Loading…
x
Reference in New Issue
Block a user