Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/cruft-prs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
run: uvx --from ./scripts send-cruft-prs ${{ env.RELEASE }} --all_repos --log-dir log
env:
RELEASE: ${{ github.event_name == 'release' && github.event.release.tag_name || github.event.inputs.release }}
GITHUB_TOKEN: ${{ secrets.BOT_GH_TOKEN }}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moving away from using an org-wide secret. See notion page for more details.

GITHUB_TOKEN: ${{ secrets.SCVERSE_BOT_PRODUCTION_GITHUB_TOKEN }}
FORCE_COLOR: "1"
COLUMNS: "150"
- uses: actions/upload-artifact@v4
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,9 @@ __pycache__/

# uv
/scripts/uv.lock

# agents
.claude

# repo-specific
cruft_logs
41 changes: 22 additions & 19 deletions scripts/src/scverse_template_scripts/cruft_prs.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ def make_pr(con: GitHubConnection, release: GHRelease, repo_url: str, *, log_dir

forked_repo = get_fork(con, original_repo)

updated = template_update(
template_update(
con,
forked_repo=forked_repo,
original_repo=original_repo,
Expand All @@ -514,24 +514,27 @@ def make_pr(con: GitHubConnection, release: GHRelease, repo_url: str, *, log_dir
if dry_run:
log.info("Skipping PR because in dry-run mode")
return
if updated:
if old_pr := next((p for p in original_repo.get_pulls("open") if pr.matches_current_version(p)), None):
log.info(f"PR already exists: #{old_pr.number} with branch name `{old_pr.head.ref}`. Skipping PR creation.")
return

if old_pr := next((p for p in original_repo.get_pulls("open") if pr.matches_prefix(p)), None):
log.info(f"Closing old PR #{old_pr.number} with branch name `{old_pr.head.ref}`.")
old_pr.edit(state="closed")

log.info(f"Creating PR of {pr.namespaced_head} against {original_repo.default_branch}")
new_pr = original_repo.create_pull(
title=pr.title,
body=pr.body,
base=original_repo.default_branch,
head=pr.namespaced_head,
maintainer_can_modify=True,
)
log.info(f"Created PR #{new_pr.number} with branch name `{new_pr.head.ref}`.")

# check against all PRs, including closed ones -- if one already exists for the current version,
# and the developer closed it, we do not want to reopen it.
if old_pr := next((p for p in original_repo.get_pulls("all") if pr.matches_current_version(p)), None):
log.info(f"PR already exists: #{old_pr.number} with branch name `{old_pr.head.ref}`. Skipping PR creation.")
return

# check if there's a PR open for an earlier version -- if yes, we close it (in favor of the new one to be created)
if old_pr := next((p for p in original_repo.get_pulls("open") if pr.matches_prefix(p)), None):
log.info(f"Closing old PR #{old_pr.number} with branch name `{old_pr.head.ref}`.")
old_pr.edit(state="closed")

log.info(f"Creating PR of {pr.namespaced_head} against {original_repo.default_branch}")
new_pr = original_repo.create_pull(
title=pr.title,
body=pr.body,
base=original_repo.default_branch,
head=pr.namespaced_head,
maintainer_can_modify=True,
)
log.info(f"Created PR #{new_pr.number} with branch name `{new_pr.head.ref}`.")


cli = App()
Expand Down
Loading