Skip to content

Commit f4f934b

Browse files
committed
Bug fixes and improvements.
1 parent 18f328e commit f4f934b

1 file changed

Lines changed: 28 additions & 11 deletions

File tree

.github/workflows/create-backport-prs.yml

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ jobs:
200200
MATRIX_BRANCH: ${{ matrix.branch }}
201201
HEAD_BRANCH_SUFFIX: ${{ needs.resolve-context.outputs.branch-suffix }}
202202
run: |
203-
BRANCH_NAME="backport/${MATRIX_BRANCH}-${HEAD_BRANCH_SUFFIX}"
203+
BRANCH_NAME="backport-${MATRIX_BRANCH}/${HEAD_BRANCH_SUFFIX}"
204204
205205
if git ls-remote --exit-code --heads origin "${BRANCH_NAME}" > /dev/null 2>&1; then
206206
echo "::error::Branch '${BRANCH_NAME}' already exists on origin."
@@ -286,7 +286,6 @@ jobs:
286286
git cherry-pick --abort 2>/dev/null || git reset --hard HEAD
287287
RESULTS="${RESULTS}${PR_NUMBER}=❌ "
288288
FAILED=true
289-
break
290289
fi
291290
done
292291
@@ -300,7 +299,7 @@ jobs:
300299
env:
301300
MATRIX_BRANCH: ${{ matrix.branch }}
302301
HEAD_BRANCH_SUFFIX: ${{ needs.resolve-context.outputs.branch-suffix }}
303-
run: git push -u origin "backport/${MATRIX_BRANCH}-${HEAD_BRANCH_SUFFIX}"
302+
run: git push -u origin "backport-${MATRIX_BRANCH}/${HEAD_BRANCH_SUFFIX}"
304303

305304
- name: Save results
306305
if: always()
@@ -317,7 +316,7 @@ jobs:
317316
318317
- name: Upload results
319318
if: always()
320-
uses: actions/upload-artifact@v4
319+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
321320
with:
322321
name: apply-results-${{ matrix.branch }}
323322
path: apply-results/
@@ -346,7 +345,7 @@ jobs:
346345
steps:
347346
- name: Download apply result
348347
id: apply-result
349-
uses: actions/download-artifact@v4
348+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
350349
with:
351350
name: apply-results-${{ matrix.branch }}
352351
path: apply-result/
@@ -366,7 +365,7 @@ jobs:
366365
REPO_SOURCE: ${{ inputs.repo-source }}
367366
PR_TARGET: ${{ inputs.pr-target }}
368367
run: |
369-
BACKPORT_BRANCH="backport/${MATRIX_BRANCH}-${HEAD_BRANCH_SUFFIX}"
368+
BACKPORT_BRANCH="backport-${MATRIX_BRANCH}/${HEAD_BRANCH_SUFFIX}"
370369
371370
if [ "${REPO_SOURCE}" = "upstream" ]; then
372371
SOURCE_REPO="${UPSTREAM_REPO}"
@@ -402,6 +401,8 @@ jobs:
402401
done
403402
fi
404403
404+
BODY="${BODY}\n\n---\n\nThis PR was generated from a [GitHub Actions workflow run](${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}) triggered by @${GITHUB_ACTOR}."
405+
405406
if [ "${PR_TARGET}" = "upstream" ]; then
406407
PR_REPO="${UPSTREAM_REPO}"
407408
PR_HEAD="${GITHUB_REPOSITORY_OWNER}:${BACKPORT_BRANCH}"
@@ -434,6 +435,7 @@ jobs:
434435
PR_URL: ${{ steps.create-pr.outputs.url }}
435436
COMMIT_SHA: ${{ inputs.commit-sha }}
436437
PR_NUMBERS: ${{ inputs.pr_numbers }}
438+
PR_NAME: ${{ inputs.pr-name }}
437439
run: |
438440
mkdir -p summary-row
439441
SAFE_BRANCH=$(echo "${MATRIX_BRANCH}" | tr '.' '-')
@@ -443,7 +445,22 @@ jobs:
443445
MERGE_RESULTS=$(grep '^merge_results=' "apply-result/${SAFE_BRANCH}.txt" | cut -d= -f2-)
444446
fi
445447
446-
PR_DISPLAY="${PR_URL:-N/A}"
448+
RUN_URL="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"
449+
450+
if [ -n "${PR_URL}" ]; then
451+
if [ -n "${PR_NUMBERS}" ] && [ -z "${COMMIT_SHA}" ]; then
452+
PR_DISPLAY="${PR_URL}"
453+
else
454+
if [ -n "${PR_NAME}" ]; then
455+
PR_TITLE="${PR_NAME} - ${MATRIX_BRANCH} branch"
456+
else
457+
PR_TITLE="Backport to ${MATRIX_BRANCH}"
458+
fi
459+
PR_DISPLAY="[${PR_TITLE}](${PR_URL})"
460+
fi
461+
else
462+
PR_DISPLAY="[View log](${RUN_URL})"
463+
fi
447464
448465
if [ -n "${PR_NUMBERS}" ] && [ -z "${COMMIT_SHA}" ]; then
449466
IFS=',' read -ra PR_LIST <<< "${PR_NUMBERS}"
@@ -462,7 +479,7 @@ jobs:
462479
463480
- name: Upload summary row
464481
if: always()
465-
uses: actions/upload-artifact@v4
482+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
466483
with:
467484
name: summary-row-${{ matrix.branch }}
468485
path: summary-row/
@@ -475,12 +492,12 @@ jobs:
475492
# - Writes the table header and appends all rows to the workflow summary.
476493
report:
477494
name: Backport report
478-
needs: [ 'backport', 'create-pr' ]
495+
needs: [ 'validate-inputs', 'backport', 'create-pr' ]
479496
runs-on: ubuntu-24.04
480-
if: always()
497+
if: ${{ always() && needs.validate-inputs.result != 'failure' }}
481498
steps:
482499
- name: Download summary rows
483-
uses: actions/download-artifact@v4
500+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
484501
with:
485502
pattern: summary-row-*
486503
path: summary-rows/

0 commit comments

Comments
 (0)