ci: store coverage badge via repo contents API
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Cinco Euzebio 2026-02-28 21:29:29 -03:00
parent f1b5b4e304
commit 801a2c08fb
2 changed files with 13 additions and 5 deletions

View File

@ -31,13 +31,21 @@ steps:
else COLOR="red"; fi
curl -sf "https://img.shields.io/badge/coverage-${PCT}%25-${COLOR}.svg" -o coverage.svg
- |
curl -sf -X DELETE \
SHA=$(curl -sf \
-H "Authorization: token $GITEA_TOKEN" \
"https://git.cincoeuzebio.com/api/packages/cinco/generic/badges/latest" || true
"https://git.cincoeuzebio.com/api/v1/repos/cinco/Tmuxido/contents/badges/coverage.svg?ref=master" \
| jq -r '.sha // empty')
CONTENT=$(base64 -w 0 coverage.svg)
if [ -n "$SHA" ]; then
PAYLOAD="{\"message\":\"ci: update coverage badge [CI SKIP]\",\"content\":\"$CONTENT\",\"sha\":\"$SHA\",\"branch\":\"master\"}"
else
PAYLOAD="{\"message\":\"ci: add coverage badge [CI SKIP]\",\"content\":\"$CONTENT\",\"branch\":\"master\"}"
fi
curl -fsSL -X PUT \
-H "Authorization: token $GITEA_TOKEN" \
-T coverage.svg \
"https://git.cincoeuzebio.com/api/packages/cinco/generic/badges/latest/coverage.svg"
-H "Content-Type: application/json" \
"https://git.cincoeuzebio.com/api/v1/repos/cinco/Tmuxido/contents/badges/coverage.svg" \
-d "$PAYLOAD"
---
kind: pipeline

View File

@ -1,7 +1,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/api/packages/cinco/generic/badges/latest/coverage.svg)](https://drone.cincoeuzebio.com/cinco/Tmuxido)
[![Coverage](https://git.cincoeuzebio.com/cinco/Tmuxido/raw/branch/master/badges/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)