🐛 fix(ci): gerar badge SVG inline e remover tr com octais
This commit is contained in:
parent
29ff9535a7
commit
b4877007f2
16
.drone.yml
16
.drone.yml
@ -26,18 +26,18 @@ steps:
|
|||||||
apt-get update -qq && apt-get install -y -qq jq curl
|
apt-get update -qq && apt-get install -y -qq jq curl
|
||||||
PCT=$(cargo tarpaulin 2>&1 | awk '/coverage,/{print int($1)}')
|
PCT=$(cargo tarpaulin 2>&1 | awk '/coverage,/{print int($1)}')
|
||||||
[ -z "$PCT" ] && PCT=0
|
[ -z "$PCT" ] && PCT=0
|
||||||
if [ "$PCT" -ge 80 ]; then COLOR="brightgreen"
|
if [ "$PCT" -ge 80 ]; then FILL="#4c1"
|
||||||
elif [ "$PCT" -ge 60 ]; then COLOR="yellow"
|
elif [ "$PCT" -ge 60 ]; then FILL="#dfb317"
|
||||||
else COLOR="red"; fi
|
else FILL="#e05d44"; fi
|
||||||
echo "PCT=$PCT COLOR=$COLOR"
|
echo "PCT=$PCT FILL=$FILL"
|
||||||
curl -sf "https://img.shields.io/badge/coverage-${PCT}%25-${COLOR}.svg" -o 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=$(cat coverage.svg | base64 | tr -d '\n')
|
CONTENT=$(base64 coverage.svg | tr -d '\n')
|
||||||
echo "Content length: ${#CONTENT}"
|
echo "Content length: ${#CONTENT}"
|
||||||
SHA_RESP=$(curl -s \
|
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=master")
|
"https://git.cincoeuzebio.com/api/v1/repos/cinco/Tmuxido/contents/badges/coverage.svg?ref=master")
|
||||||
echo "SHA response: $SHA_RESP"
|
echo "SHA response: $SHA_RESP"
|
||||||
SHA=$(echo "$SHA_RESP" | tr -d '\000-\037' | jq -r '.sha // empty')
|
SHA=$(echo "$SHA_RESP" | jq -r '.sha // empty')
|
||||||
echo "SHA: '$SHA'"
|
echo "SHA: '$SHA'"
|
||||||
if [ -n "$SHA" ]; then
|
if [ -n "$SHA" ]; then
|
||||||
PAYLOAD=$(jq -n --arg msg "ci: update coverage badge [CI SKIP]" \
|
PAYLOAD=$(jq -n --arg msg "ci: update coverage badge [CI SKIP]" \
|
||||||
@ -59,7 +59,7 @@ steps:
|
|||||||
-d "$PAYLOAD")
|
-d "$PAYLOAD")
|
||||||
fi
|
fi
|
||||||
echo "API response: $RESPONSE"
|
echo "API response: $RESPONSE"
|
||||||
echo "$RESPONSE" | tr -d '\000-\037' | jq -e '.content.sha' > /dev/null
|
echo "$RESPONSE" | tr -d '\n' | jq -e '.content.sha' > /dev/null
|
||||||
|
|
||||||
---
|
---
|
||||||
kind: pipeline
|
kind: pipeline
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user