Skip to content

Commit 843247b

Browse files
authored
[PM-16211] chore(ci): Fix hotfix branch creation workflow by retrieving the last tag across all branches (#4491)
1 parent efbb844 commit 843247b

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

.github/workflows/release-branch.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ on:
1010
options:
1111
- RC
1212
- Hotfix
13-
rc_prefix_date:
14-
description: 'RC - Prefix with date. E.g. 2024.11-rc1'
15-
type: boolean
16-
default: true
1713

1814
jobs:
1915
create-release-branch:
@@ -30,7 +26,7 @@ jobs:
3026
- name: Create RC Branch
3127
if: inputs.release_type == 'RC'
3228
env:
33-
RC_PREFIX_DATE: ${{ inputs.rc_prefix_date }}
29+
RC_PREFIX_DATE: "true" # replace with input if needed
3430
run: |
3531
if [ "$RC_PREFIX_DATE" = "true" ]; then
3632
current_date=$(date +'%Y.%m')
@@ -46,12 +42,17 @@ jobs:
4642
- name: Create Hotfix Branch
4743
if: inputs.release_type == 'Hotfix'
4844
run: |
49-
latest_tag=$(git describe --tags --abbrev=0)
45+
latest_tag=$(git tag -l --sort=-creatordate | head -n 1)
5046
if [ -z "$latest_tag" ]; then
5147
echo "::error::No tags found in the repository"
5248
exit 1
5349
fi
5450
branch_name="release/hotfix-${latest_tag}"
51+
echo "🌿 branch name: $branch_name"
52+
if git show-ref --verify --quiet "refs/remotes/origin/$branch_name"; then
53+
echo "# :fire: :warning: Hotfix branch already exists: ${branch_name}" >> $GITHUB_STEP_SUMMARY
54+
exit 0
55+
fi
5556
git switch -c $branch_name $latest_tag
5657
git push origin $branch_name
5758
echo "# :fire: Hotfix branch: ${branch_name}" >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)