🤖 feat: implement KISS badge update using environment variables
All checks were successful
CI/CD Pipeline / Build Docker Cache (push) Successful in 9s
CI/CD Pipeline / CI Pipeline (push) Successful in 4m52s

- Fix badge URLs and remove duplicates
- Add update-all-badges.sh script for single commit updates
- Update CI/CD workflow to use environment variables
- Remove complex sequential commit logic
- Follow KISS principle with simple env var approach
This commit is contained in:
2026-04-08 15:21:41 +02:00
parent 1fb15fc331
commit 0b6f18f33c
3 changed files with 90 additions and 16 deletions

View File

@@ -199,14 +199,10 @@ jobs:
# Generate BDD coverage report
go tool cover -func=coverage.out > bdd_coverage.txt
# Extract BDD coverage percentage
# Extract BDD coverage percentage and set as environment variable
BDD_COVERAGE=$(grep "total:" bdd_coverage.txt | grep -oP '\d+\.\d+' | head -1)
echo "BDD Coverage: ${BDD_COVERAGE}%"
# Update BDD coverage badge
export PACKAGES_TOKEN="${{ secrets.PACKAGES_TOKEN }}"
export GITHUB_REF_NAME="${{ github.ref_name }}"
./scripts/ci-update-coverage-badge.sh "$BDD_COVERAGE" "bdd"
echo "DLC_BDD_COVERAGE=${BDD_COVERAGE}%" >> $GITHUB_ENV
- name: Run unit tests with coverage
run: |
@@ -217,14 +213,10 @@ jobs:
# Generate unit coverage report
go tool cover -func=unit_coverage.out > unit_coverage.txt
# Extract unit test coverage percentage
# Extract unit test coverage percentage and set as environment variable
UNIT_COVERAGE=$(grep "total:" unit_coverage.txt | grep -oP '\d+\.\d+' | head -1)
echo "Unit Coverage: ${UNIT_COVERAGE}%"
# Update unit test coverage badge
export PACKAGES_TOKEN="${{ secrets.PACKAGES_TOKEN }}"
export GITHUB_REF_NAME="${{ github.ref_name }}"
./scripts/ci-update-coverage-badge.sh "$UNIT_COVERAGE" "unit"
echo "DLC_UNIT_COVERAGE=${UNIT_COVERAGE}%" >> $GITHUB_ENV
- name: Run go fmt
run: go fmt ./...
@@ -244,6 +236,39 @@ jobs:
# path: pkg/server/docs/swagger.json
# retention-days: 1
# Single badge update step using environment variables (KISS approach)
- name: Update all badges (single commit)
if: always() && github.ref == 'refs/heads/main' && github.actor != 'ci-bot'
run: |
echo "🎯 Updating all badges using environment variables..."
echo "BDD Coverage: ${DLC_BDD_COVERAGE:-Not set}"
echo "Unit Coverage: ${DLC_UNIT_COVERAGE:-Not set}"
# Extract coverage values (remove % sign)
BDD_COV=${DLC_BDD_COVERAGE%"%"}
UNIT_COV=${DLC_UNIT_COVERAGE%"%"}
# Update badges only if values are set
if [ -n "$BDD_COV" ] || [ -n "$UNIT_COV" ]; then
./scripts/update-all-badges.sh "$BDD_COV" "$UNIT_COV"
# Configure git
git config user.name "CI Bot"
git config user.email "ci@arcodange.fr"
git add README.md
# Commit only if there are changes
if git commit -m "🤖 chore: update coverage badges [skip ci]"; then
echo "✅ Badges updated, committing changes..."
git push
echo "🎉 Successfully pushed badge updates"
else
echo " No badge changes to commit"
fi
else
echo "⚠️ No coverage data available to update badges"
fi
# Docker build and push (main branch only)
- name: Login to Gitea Container Registry
if: github.ref == 'refs/heads/main'