Skip to content

Commit bb48d91

Browse files
author
Evilazaro Alves
committed
Fix: Tag Creation Error
1 parent f070336 commit bb48d91

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

.github/actions/ci/bicep-standard-ci/action.yml

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -289,22 +289,27 @@ runs:
289289
branch_name="${{ steps.branch_info.outputs.branch_name }}"
290290
should_publish="${{ steps.determine_release_type.outputs.should_publish }}"
291291
292-
echo "🏷️ Creating tag: $tag_name"
292+
echo "🏷️ Preparing to create tag: $tag_name"
293293
echo "🔀 For branch: $branch_name"
294294
echo "📋 Will publish release: $should_publish"
295295
296-
# Create annotated tag
297-
if [[ "$branch_name" == "main" ]]; then
298-
git tag -a "$tag_name" -m "Release $tag_name from main branch"
299-
else
300-
git tag -a "$tag_name" -m "Development tag $tag_name from $branch_name branch (no release)"
301-
fi
302-
303-
# Fetch latest tags and set up authentication before pushing
296+
# Fetch latest tags first to check for existing tags
304297
git fetch --tags --force
298+
299+
# Check if tag already exists before creating it
305300
if git rev-parse "$tag_name" >/dev/null 2>&1; then
306-
echo "⚠️ Tag $tag_name already exists. Skipping push."
301+
echo "⚠️ Tag $tag_name already exists locally or remotely. Skipping tag creation and push."
307302
else
303+
echo "✅ Tag $tag_name does not exist. Creating new tag..."
304+
305+
# Create annotated tag
306+
if [[ "$branch_name" == "main" ]]; then
307+
git tag -a "$tag_name" -m "Release $tag_name from main branch"
308+
else
309+
git tag -a "$tag_name" -m "Development tag $tag_name from $branch_name branch (no release)"
310+
fi
311+
312+
# Push the newly created tag
308313
git push origin "$tag_name"
309314
echo "✅ Tag $tag_name created and pushed successfully"
310315
fi

0 commit comments

Comments
 (0)