refactor: improve PR creation error handling and remove trailing whitespace
Co-authored-by: jmiller-moko <230051081+jmiller-moko@users.noreply.github.com>
This commit is contained in:
30
.github/workflows/version_branch.yml
vendored
30
.github/workflows/version_branch.yml
vendored
@@ -651,18 +651,32 @@ jobs:
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
echo "[INFO] Creating pull request from ${BRANCH_NAME} to ${BASE_BRANCH}"
|
echo "[INFO] Creating pull request from ${BRANCH_NAME} to ${BASE_BRANCH}"
|
||||||
|
|
||||||
gh pr create \
|
set +e
|
||||||
|
PR_OUTPUT=$(gh pr create \
|
||||||
--base "${BASE_BRANCH}" \
|
--base "${BASE_BRANCH}" \
|
||||||
--head "${BRANCH_NAME}" \
|
--head "${BRANCH_NAME}" \
|
||||||
--title "${PR_TITLE}" \
|
--title "${PR_TITLE}" \
|
||||||
--body-file /tmp/pr_body.txt \
|
--body-file /tmp/pr_body.txt 2>&1)
|
||||||
|| {
|
PR_EXIT_CODE=$?
|
||||||
echo "[WARN] Failed to create pull request. It may already exist or there may be no changes." >&2
|
set -e
|
||||||
exit 0
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
- name: Publish audit trail
|
||||||
if: always()
|
if: always()
|
||||||
|
|||||||
Reference in New Issue
Block a user