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:
Cinco Euzebio 2026-02-28 23:16:03 -03:00
parent 90e3b65820
commit e6180b57c3
3 changed files with 5 additions and 30 deletions

View File

@ -31,35 +31,11 @@ steps:
else FILL="#e05d44"; fi
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
CONTENT=$(base64 coverage.svg | tr -d '\n')
echo "Content length: ${#CONTENT}"
SHA_RESP=$(curl -s \
curl -fsSL -X PUT \
-H "Authorization: token $GITEA_TOKEN" \
"https://git.cincoeuzebio.com/api/v1/repos/cinco/Tmuxido/contents/badges/coverage.svg?ref=main")
echo "SHA response: $SHA_RESP"
SHA=$(echo "$SHA_RESP" | jq -r '.sha // empty')
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
-H "Content-Type: image/svg+xml" \
--data-binary @coverage.svg \
"https://git.cincoeuzebio.com/api/packages/cinco/generic/badges/latest/coverage.svg"
---
kind: pipeline

View File

@ -5,7 +5,7 @@
# tmuxido
[![Build Status](https://drone.cincoeuzebio.com/api/badges/cinco/Tmuxido/status.svg)](https://drone.cincoeuzebio.com/cinco/Tmuxido)
[![Coverage](https://git.cincoeuzebio.com/cinco/Tmuxido/raw/branch/main/badges/coverage.svg)](https://drone.cincoeuzebio.com/cinco/Tmuxido)
[![Coverage](https://git.cincoeuzebio.com/api/packages/cinco/generic/badges/latest/coverage.svg)](https://drone.cincoeuzebio.com/cinco/Tmuxido)
[![Version](https://img.shields.io/gitea/v/release/cinco/Tmuxido?gitea_url=https%3A%2F%2Fgit.cincoeuzebio.com&label=version)](https://git.cincoeuzebio.com/cinco/Tmuxido/releases)
![Rust 2024](https://img.shields.io/badge/rust-edition_2024-orange?logo=rust)

View File

@ -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