🐛 fix: ensure single push in CI/CD workflow
This commit is contained in:
@@ -253,25 +253,25 @@ jobs:
|
||||
BDD_COV=${DLC_BDD_COVERAGE%"%"}
|
||||
UNIT_COV=${DLC_UNIT_COVERAGE%"%"}
|
||||
|
||||
# Update BDD coverage badge if value is set
|
||||
# Update BDD coverage badge if value is set (use --no-push to avoid race conditions)
|
||||
if [ -n "$BDD_COV" ]; then
|
||||
echo "📊 Updating BDD coverage badge to ${BDD_COV}%"
|
||||
./scripts/ci-update-coverage-badge.sh "$BDD_COV" "bdd"
|
||||
./scripts/ci-update-coverage-badge.sh "$BDD_COV" "bdd" --no-push
|
||||
fi
|
||||
|
||||
# Update Unit coverage badge if value is set
|
||||
# Update Unit coverage badge if value is set (use --no-push to avoid race conditions)
|
||||
if [ -n "$UNIT_COV" ]; then
|
||||
echo "📊 Updating Unit coverage badge to ${UNIT_COV}%"
|
||||
./scripts/ci-update-coverage-badge.sh "$UNIT_COV" "unit"
|
||||
./scripts/ci-update-coverage-badge.sh "$UNIT_COV" "unit" --no-push
|
||||
fi
|
||||
|
||||
# Check for version bump on main branch
|
||||
if [ "${{ github.ref }}" = "refs/heads/main" ]; then
|
||||
echo "🔖 Checking for version bump..."
|
||||
./scripts/version-bump-auto.sh
|
||||
./scripts/ci-version-bump.sh "${{ github.event.head_commit.message }}" --no-push
|
||||
fi
|
||||
|
||||
# Single push for all commits
|
||||
# Single push for all commits (this is the ONLY push in the entire workflow)
|
||||
if [ -n "$(git status --porcelain)" ]; then
|
||||
echo "💾 Changes detected, pushing all commits..."
|
||||
git push
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#!/bin/bash
|
||||
# CI script to update coverage badge in README.md
|
||||
# Usage: scripts/ci-update-coverage-badge.sh <coverage_percentage> [badge_type]
|
||||
# Usage: scripts/ci-update-coverage-badge.sh <coverage_percentage> [badge_type] [flags]
|
||||
# badge_type can be "bdd", "unit", or empty for combined coverage
|
||||
# flags: --no-commit (skip git commit), --no-push (skip git push)
|
||||
|
||||
set -e
|
||||
|
||||
@@ -13,6 +14,18 @@ fi
|
||||
COVERAGE=$1
|
||||
BADGE_TYPE=${2:-"combined"}
|
||||
|
||||
# Parse flags
|
||||
NO_COMMIT=false
|
||||
NO_PUSH=false
|
||||
|
||||
for arg in "$@"; do
|
||||
if [ "$arg" = "--no-commit" ]; then
|
||||
NO_COMMIT=true
|
||||
elif [ "$arg" = "--no-push" ]; then
|
||||
NO_PUSH=true
|
||||
fi
|
||||
done
|
||||
|
||||
# Determine badge color
|
||||
if (( $(echo "$COVERAGE >= 80" | bc -l) )); then
|
||||
COLOR="brightgreen"
|
||||
@@ -76,7 +89,22 @@ if [ -n "$PACKAGES_TOKEN" ]; then
|
||||
fi
|
||||
|
||||
git add README.md
|
||||
|
||||
# Skip commit if --no-commit flag is set
|
||||
if [ "$NO_COMMIT" = true ]; then
|
||||
echo "Skipping git commit due to --no-commit flag"
|
||||
echo "Coverage badge updated to ${COVERAGE}% in README.md (not committed)"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if git commit -m "🤖 chore: update coverage badge to ${COVERAGE}% [skip ci]"; then
|
||||
# Skip push if --no-push flag is set
|
||||
if [ "$NO_PUSH" = true ]; then
|
||||
echo "Skipping git push due to --no-push flag"
|
||||
echo "Coverage badge updated to ${COVERAGE}% and committed locally"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Try push with retry logic for race conditions
|
||||
for i in 1 2 3; do
|
||||
if git push; then
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
# CI script to handle automatic version bumping
|
||||
# Usage: scripts/ci-version-bump.sh <commit_message>
|
||||
# Usage: scripts/ci-version-bump.sh <commit_message> [--no-push]
|
||||
|
||||
set -e
|
||||
|
||||
@@ -11,6 +11,14 @@ fi
|
||||
|
||||
LAST_COMMIT=$1
|
||||
VERSION_BUMPED="false"
|
||||
NO_PUSH=false
|
||||
|
||||
# Parse flags
|
||||
for arg in "$@"; do
|
||||
if [ "$arg" = "--no-push" ]; then
|
||||
NO_PUSH=true
|
||||
fi
|
||||
done
|
||||
|
||||
# Automatic version bump based on commit type
|
||||
if echo "$LAST_COMMIT" | grep -q "^✨ feat:"; then
|
||||
@@ -47,6 +55,13 @@ if [ "$VERSION_BUMPED" = "true" ]; then
|
||||
|
||||
git add VERSION cmd/server/main.go README.md
|
||||
if git commit -m "chore: auto version bump [skip ci]"; then
|
||||
# Skip push if --no-push flag is set
|
||||
if [ "$NO_PUSH" = true ]; then
|
||||
echo "Skipping git push due to --no-push flag"
|
||||
echo "Successfully bumped version to $NEW_VERSION (committed locally)"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Try push with retry logic for race conditions
|
||||
for i in 1 2 3; do
|
||||
if git push; then
|
||||
|
||||
Reference in New Issue
Block a user