1313 if : github.event.pull_request.merged == true
1414 runs-on : ubuntu-latest
1515 permissions :
16- contents : write # To push branches and commit changes
16+ contents : write # To push branches and commit changes
1717 pull-requests : write # To create the pull request
1818
1919 env :
@@ -114,20 +114,21 @@ jobs:
114114 - name : Create and Process Hotfix Branches
115115 env :
116116 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
117+ PR_TITLE : ${{ github.event.pull_request.title }}
117118 run : |
118119 # Read branch pairs and process each one
119120 IFS=' ' read -r -a PAIRS <<< "${{ steps.define_branches.outputs.branch_pairs }}"
120-
121+
121122 for pair in "${PAIRS[@]}"; do
122123 IFS=':' read -r base_branch new_branch <<< "$pair"
123-
124+
124125 echo "Processing hotfix for branch: $base_branch"
125-
126+
126127 # Create and switch to new branch
127128 git checkout "$base_branch"
128129 git pull origin "$base_branch"
129130 git checkout -b "$new_branch"
130-
131+
131132 # Attempt cherry-pick
132133 if ! git cherry-pick ${{ steps.get_commit.outputs.sha }} --empty=keep; then
133134 echo "Cherry-pick encountered conflicts for $base_branch, attempting to resolve..."
@@ -139,7 +140,7 @@ jobs:
139140 continue # Skip PR creation if no changes after resolution
140141 fi
141142 git cherry-pick --continue
142-
143+
143144 if [ $? -eq 0 ]; then
144145 echo "Successfully resolved conflicts for $base_branch"
145146 had_conflicts="true"
@@ -166,18 +167,18 @@ jobs:
166167 # Push branch
167168 if git push origin "$new_branch"; then
168169 echo "Successfully pushed branch $new_branch"
169-
170+
170171 # Create PR
171172 PR_NUMBER="${{ github.event.pull_request.number }}"
172173 PR_URL="${{ github.event.pull_request.html_url }}"
173174 PR_AUTHOR="${{ github.event.pull_request.user.login }}"
174175
175176 # Adjust PR title based on the target branch
176177 if [[ "$base_branch" == "main" ]]; then
177- PR_TITLE ="[Hotfix Main]: ${{ github.event.pull_request.title }} "
178+ HOTFIX_PR_TITLE ="[Hotfix Main]: $PR_TITLE "
178179 else
179180 base_branch_name=${base_branch#"release-candidate/"}
180- PR_TITLE ="[Hotfix $base_branch_name]: ${{ github.event.pull_request.title }} "
181+ HOTFIX_PR_TITLE ="[Hotfix $base_branch_name]: $PR_TITLE "
181182 fi
182183
183184 PR_BODY="Hotfix of PR #${PR_NUMBER} (${PR_URL}) to the \`${base_branch}\` branch.
@@ -189,9 +190,10 @@ jobs:
189190
190191 ### ⚠️ **Note:** This PR had conflicts with the base branch and was resolved automatically. Please review the changes carefully."
191192 fi
192-
193+
194+ # Create PR using gh cli
193195 gh pr create \
194- --title "$PR_TITLE " \
196+ --title "$HOTFIX_PR_TITLE " \
195197 --body "$PR_BODY" \
196198 --head "$new_branch" \
197199 --base "$base_branch" \
0 commit comments