feat: add automatic PR creation when version branch is created
Co-authored-by: jmiller-moko <230051081+jmiller-moko@users.noreply.github.com>
This commit is contained in:
44
.github/workflows/version_branch.yml
vendored
44
.github/workflows/version_branch.yml
vendored
@@ -44,6 +44,7 @@ concurrency:
|
|||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
|
pull-requests: write
|
||||||
|
|
||||||
defaults:
|
defaults:
|
||||||
run:
|
run:
|
||||||
@@ -620,6 +621,49 @@ jobs:
|
|||||||
|
|
||||||
git push --set-upstream origin "${BRANCH_NAME}"
|
git push --set-upstream origin "${BRANCH_NAME}"
|
||||||
|
|
||||||
|
- name: Create pull request
|
||||||
|
if: ${{ env.REPORT_ONLY != 'true' }}
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ github.token }}
|
||||||
|
run: |
|
||||||
|
source "$CI_HELPERS"
|
||||||
|
moko_init "Create pull request"
|
||||||
|
|
||||||
|
if [[ -z "${BRANCH_NAME:-}" ]]; then
|
||||||
|
echo "[FATAL] BRANCH_NAME not set." >&2
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
|
||||||
|
PR_TITLE="Version branch ${NEW_VERSION}"
|
||||||
|
if [[ -n "${VERSION_TEXT}" ]]; then
|
||||||
|
PR_TITLE="${PR_TITLE} (${VERSION_TEXT})"
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat > /tmp/pr_body.txt <<EOF
|
||||||
|
Automated pull request created for version branch \`${BRANCH_NAME}\`.
|
||||||
|
|
||||||
|
Version: ${NEW_VERSION}
|
||||||
|
Version Text: ${VERSION_TEXT:-N/A}
|
||||||
|
Branch Prefix: ${BRANCH_PREFIX}
|
||||||
|
Base Branch: ${BASE_BRANCH}
|
||||||
|
|
||||||
|
This PR was automatically created by the version branch workflow.
|
||||||
|
EOF
|
||||||
|
|
||||||
|
echo "[INFO] Creating pull request from ${BRANCH_NAME} to ${BASE_BRANCH}"
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "[INFO] Pull request created successfully"
|
||||||
|
|
||||||
- name: Publish audit trail
|
- name: Publish audit trail
|
||||||
if: always()
|
if: always()
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
Reference in New Issue
Block a user