Update merge-main-into-prs.yml (#10032)
Co-authored-by: Ultralytics AI Assistant <135830346+UltralyticsAssistant@users.noreply.github.com>
This commit is contained in:
parent
d608565a17
commit
a506a55062
1 changed files with 9 additions and 5 deletions
10
.github/workflows/merge-main-into-prs.yml
vendored
10
.github/workflows/merge-main-into-prs.yml
vendored
|
|
@ -19,6 +19,7 @@ jobs:
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
ref: main
|
||||||
- uses: actions/setup-python@v5
|
- uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: "3.11"
|
python-version: "3.11"
|
||||||
|
|
@ -43,9 +44,12 @@ jobs:
|
||||||
|
|
||||||
for pr in open_pulls:
|
for pr in open_pulls:
|
||||||
try:
|
try:
|
||||||
# Attempt to merge main into the PR branch
|
# Compare PR head with main to see if it's behind
|
||||||
message = f"Merge 'main' into PR #{pr.number} by https://ultralytics.com/actions"
|
comparison = repo.compare(pr.base.ref, pr.head.ref) # ensure correct order of base and head
|
||||||
merge_commit = repo.merge(pr.head.ref, 'main', commit_message=message)
|
if comparison.behind_by > 0:
|
||||||
|
# Merge main into the PR branch
|
||||||
|
success = pr.update_branch()
|
||||||
|
assert success, "Branch update failed"
|
||||||
print(f"Merged 'main' into PR #{pr.number} ({pr.head.ref}) successfully.")
|
print(f"Merged 'main' into PR #{pr.number} ({pr.head.ref}) successfully.")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Could not merge 'main' into PR #{pr.number} ({pr.head.ref}): {e}")
|
print(f"Could not merge 'main' into PR #{pr.number} ({pr.head.ref}): {e}")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue