Files
dance-lessons-coach/scripts/update-all-badges.sh
Gabriel Radureau 9d42909b86
All checks were successful
CI/CD Pipeline / Build Docker Cache (push) Successful in 9s
CI/CD Pipeline / CI Pipeline (push) Successful in 5m0s
🐛 fix: make badge update script cross-platform compatible
- Detect macOS vs Linux sed syntax automatically
- Use appropriate sed command for each platform
- Fixes workflow failure in Docker container

macOS: sed -i '' (BSD sed)
Linux: sed -i (GNU sed)
2026-04-08 15:41:21 +02:00

62 lines
1.7 KiB
Bash
Executable File
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# Simple script to update coverage badges in README.md
# Usage: ./scripts/update-all-badges.sh [bdd_coverage] [unit_coverage]
# Both parameters are optional - only updates what's provided
set -e
BDD_COVERAGE=""
UNIT_COVERAGE=""
# Parse arguments (both optional)
if [ -n "$1" ]; then
BDD_COVERAGE=$1
fi
if [ -n "$2" ]; then
UNIT_COVERAGE=$2
fi
echo "🎯 Updating coverage badges..."
if [ -n "$BDD_COVERAGE" ]; then
echo " BDD: ${BDD_COVERAGE}%"
fi
if [ -n "$UNIT_COVERAGE" ]; then
echo " Unit: ${UNIT_COVERAGE}%"
fi
# Cross-platform sed command
# Detect if we're on macOS (BSD sed) or Linux (GNU sed)
SED_CMD=""
if [[ "$(uname)" == "Darwin" ]]; then
# macOS - requires empty string after -i
SED_CMD="sed -i ''"
else
# Linux - standard GNU sed
SED_CMD="sed -i"
fi
# Update BDD coverage badge if provided
if [ -n "$BDD_COVERAGE" ] && grep -q "BDD_Coverage" README.md; then
$SED_CMD "s/BDD_Coverage-[0-9.]\+-%/BDD_Coverage-${BDD_COVERAGE}-%/g" README.md
echo "✅ BDD coverage badge updated to ${BDD_COVERAGE}%"
fi
# Update Unit coverage badge if provided
if [ -n "$UNIT_COVERAGE" ] && grep -q "Unit_Coverage" README.md; then
$SED_CMD "s/Unit_Coverage-[0-9.]\+-%/Unit_Coverage-${UNIT_COVERAGE}-%/g" README.md
echo "✅ Unit coverage badge updated to ${UNIT_COVERAGE}%"
fi
# Update main coverage badge if BDD coverage provided
if [ -n "$BDD_COVERAGE" ] && grep -q "coverage-[0-9.]\+-%" README.md; then
$SED_CMD "s/coverage-[0-9.]\+-%/coverage-${BDD_COVERAGE}-%/g" README.md
echo "✅ Main coverage badge updated to ${BDD_COVERAGE}%"
fi
if [ -z "$BDD_COVERAGE" ] && [ -z "$UNIT_COVERAGE" ]; then
echo " No coverage values provided - nothing to update"
fi
echo "🎉 Badge update process completed!"