Skip to content

Commit d02a63e

Browse files
committed
feat: Enhance Helm chart update script with current tag check and conditional commit
1 parent 80e6eaa commit d02a63e

1 file changed

Lines changed: 23 additions & 5 deletions

File tree

scripts/update-helm-chart.sh

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,17 @@ fi
6969

7070
echo "📝 Updating $VALUES_FILE with tag: $NEW_TAG"
7171

72+
# Check current tag before updating
73+
CURRENT_TAG=$(grep -E "^\s*tag:" "$VALUES_FILE" | sed 's/.*tag: *"\([^"]*\)".*/\1/')
74+
echo "📋 Current tag: $CURRENT_TAG"
75+
echo "📋 New tag: $NEW_TAG"
76+
77+
if [ "$CURRENT_TAG" = "$NEW_TAG" ]; then
78+
echo "ℹ️ Tag is already up-to-date: $NEW_TAG"
79+
else
80+
echo "🔄 Updating tag from $CURRENT_TAG to $NEW_TAG"
81+
fi
82+
7283
# Update the image tag in values.yaml using sed
7384
# This updates the line: tag: "current-tag" to tag: "new-tag"
7485
sed -i "s|tag: \".*\"|tag: \"$NEW_TAG\"|g" "$VALUES_FILE"
@@ -88,19 +99,26 @@ git diff "$VALUES_FILE"
8899
# Commit and push the changes
89100
echo "💾 Committing changes..."
90101
git add "$VALUES_FILE"
91-
git commit -m "🚀 Update $SERVICE image tag to $NEW_TAG
102+
103+
# Check if there are changes to commit
104+
if git diff --cached --quiet; then
105+
echo "ℹ️ No changes detected - tag is already up-to-date: $NEW_TAG"
106+
echo "🎉 $SERVICE is already using tag $NEW_TAG in helm-charts repository!"
107+
else
108+
git commit -m "🚀 Update $SERVICE image tag to $NEW_TAG
92109
93110
- Service: $SERVICE
94111
- Repository: $IMAGE_REPO
95112
- New tag: $NEW_TAG
96113
- Updated: $VALUES_FILE
97114
98115
Auto-generated by CI/CD pipeline"
116+
117+
echo "📤 Pushing changes to helm-charts repository..."
118+
git push origin main
119+
echo "🎉 Successfully updated $SERVICE to $NEW_TAG in helm-charts repository!"
120+
fi
99121

100-
echo "📤 Pushing changes to helm-charts repository..."
101-
git push origin main
102-
103-
echo "🎉 Successfully updated $SERVICE to $NEW_TAG in helm-charts repository!"
104122
echo "🔄 ArgoCD should automatically deploy the new version within 30 seconds"
105123

106124
# Clean up

0 commit comments

Comments
 (0)