From b619b39dde2e6f5cd00a00c2b1e1aa2ea1a1f90d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 9 Jan 2026 01:32:47 +0000 Subject: [PATCH] refactor: improve PR creation error handling and remove trailing whitespace Co-authored-by: jmiller-moko <230051081+jmiller-moko@users.noreply.github.com> --- .github/workflows/version_branch.yml | 30 ++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/.github/workflows/version_branch.yml b/.github/workflows/version_branch.yml index c449819..49959a5 100644 --- a/.github/workflows/version_branch.yml +++ b/.github/workflows/version_branch.yml @@ -651,18 +651,32 @@ jobs: EOF echo "[INFO] Creating pull request from ${BRANCH_NAME} to ${BASE_BRANCH}" - - gh pr create \ + + set +e + PR_OUTPUT=$(gh pr create \ --base "${BASE_BRANCH}" \ --head "${BRANCH_NAME}" \ --title "${PR_TITLE}" \ - --body-file /tmp/pr_body.txt \ - || { - echo "[WARN] Failed to create pull request. It may already exist or there may be no changes." >&2 - exit 0 - } + --body-file /tmp/pr_body.txt 2>&1) + PR_EXIT_CODE=$? + set -e - echo "[INFO] Pull request created successfully" + if [[ ${PR_EXIT_CODE} -eq 0 ]]; then + echo "[INFO] Pull request created successfully" + echo "${PR_OUTPUT}" + else + echo "[WARN] Failed to create pull request (exit code: ${PR_EXIT_CODE})" >&2 + echo "[WARN] Output: ${PR_OUTPUT}" >&2 + + # Check for common error conditions + if echo "${PR_OUTPUT}" | grep -iq "already exists"; then + echo "[INFO] PR likely already exists, continuing..." >&2 + elif echo "${PR_OUTPUT}" | grep -iq "no commits between"; then + echo "[INFO] No commits between branches, continuing..." >&2 + else + echo "[WARN] Unexpected error occurred, but continuing workflow" >&2 + fi + fi - name: Publish audit trail if: always()