🐛 fix(ci): unificar blocks e sanitizar JSON do Gitea antes do jq
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
eaee355f55
commit
2de294a828
11
.drone.yml
11
.drone.yml
@ -22,23 +22,22 @@ steps:
|
|||||||
GITEA_TOKEN:
|
GITEA_TOKEN:
|
||||||
from_secret: gitea_token
|
from_secret: gitea_token
|
||||||
commands:
|
commands:
|
||||||
- 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)}')
|
||||||
echo "PCT=$PCT"
|
|
||||||
[ -z "$PCT" ] && PCT=0
|
[ -z "$PCT" ] && PCT=0
|
||||||
if [ "$PCT" -ge 80 ]; then COLOR="brightgreen"
|
if [ "$PCT" -ge 80 ]; then COLOR="brightgreen"
|
||||||
elif [ "$PCT" -ge 60 ]; then COLOR="yellow"
|
elif [ "$PCT" -ge 60 ]; then COLOR="yellow"
|
||||||
else COLOR="red"; fi
|
else COLOR="red"; fi
|
||||||
|
echo "PCT=$PCT COLOR=$COLOR"
|
||||||
curl -sf "https://img.shields.io/badge/coverage-${PCT}%25-${COLOR}.svg" -o coverage.svg
|
curl -sf "https://img.shields.io/badge/coverage-${PCT}%25-${COLOR}.svg" -o coverage.svg
|
||||||
- |
|
CONTENT=$(cat coverage.svg | base64 | tr -d '\n')
|
||||||
CONTENT=$(base64 -w 0 coverage.svg)
|
|
||||||
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" | jq -r '.sha // empty')
|
SHA=$(echo "$SHA_RESP" | tr -d '\000-\037' | 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]" \
|
||||||
@ -60,7 +59,7 @@ steps:
|
|||||||
-d "$PAYLOAD")
|
-d "$PAYLOAD")
|
||||||
fi
|
fi
|
||||||
echo "API response: $RESPONSE"
|
echo "API response: $RESPONSE"
|
||||||
echo "$RESPONSE" | jq -e '.content.sha' > /dev/null
|
echo "$RESPONSE" | tr -d '\000-\037' | jq -e '.content.sha' > /dev/null
|
||||||
|
|
||||||
---
|
---
|
||||||
kind: pipeline
|
kind: pipeline
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user