Skip to content

Commit f84253e

Browse files
authored
Update merge-to-main script (#1420)
* Before creating the merge-main PR, branch it off main, so merge conflicts can be addressed in the branch rather than by committing to main. * Format.
1 parent f198c6f commit f84253e

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

.github/workflows/update-feature-branches.yml

+11-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ env:
1717
defaultBranchPattern: "feature_branch/*"
1818
defaultMainBranch: "main"
1919
triggerTestsLabel: "tests-requested: quick"
20+
branchPrefix: "workflow/auto-merge-feature-branch-"
21+
2022

2123
jobs:
2224
list_feature_branches:
@@ -85,6 +87,11 @@ jobs:
8587
python scripts/gha/install_prereqs_desktop.py
8688
python -m pip install requests
8789
90+
- name: Name new branch
91+
run: |
92+
date_str=$(date "+%Y%m%d-%H%M%S")
93+
echo "NEW_BRANCH=${{env.branchPrefix}}${{github.run_number}}-${date_str}" >> $GITHUB_ENV
94+
8895
- name: Create merge PR
8996
id: create-pr
9097
run: |
@@ -115,7 +122,10 @@ jobs:
115122
116123
> Created on ${date_str} by [${{github.workflow}} workflow]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID).
117124
"
118-
pr_number=$(python scripts/gha/create_pull_request.py --token ${{ steps.generate-token.outputs.token }} --base "${{ matrix.branch_name }}" --head "${main_branch}" --title "${pr_title}" --body "${pr_body}")
125+
git checkout main
126+
git checkout -b "${NEW_BRANCH}"
127+
git push --set-upstream origin "${NEW_BRANCH}"
128+
pr_number=$(python scripts/gha/create_pull_request.py --token ${{ steps.generate-token.outputs.token }} --base "${{ matrix.branch_name }}" --head "${NEW_BRANCH}" --title "${pr_title}" --body "${pr_body}")
119129
echo "created_pr_number=${pr_number}" >> $GITHUB_OUTPUT
120130
121131
- name: Set test trigger label.

0 commit comments

Comments
 (0)