Skip to content

fix(repo-policy-sync): cross-repository apply - #23

Merged
AlexanderLanin merged 6 commits into
mainfrom
bugfix/repo-policy-sync-apply-auth
Sep 1, 2026
Merged

AlexanderLanin merged 6 commits into
mainfrom
bugfix/repo-policy-sync-apply-auth

Conversation

@AlexanderLanin

@AlexanderLanin AlexanderLanin commented Aug 31, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Update generated pull-request bodies and labels through GitHub REST endpoints, compatible with the cross-repository bot's repo scope.
  • Configure the bot identity globally so commits in cached target-repository checkouts have an author.
  • Reject apply mode before any mutation when SCORE_BOT_CLASSIC_PAT is unavailable.
  • Keep the GitHub Step Summary focused on errors, while retaining the detailed terminal report and JSON artifact.

Why

GitHub CLI pull-request commands use GraphQL and require read:org for organization-owned repositories. The cross-repository bot deliberately has only the narrower repo scope, which is sufficient for the REST endpoints.

Verification

  • uv run --package repo-policy-sync ruff check repo_policy_sync/src repo_policy_sync/tests
  • uv run --package repo-policy-sync pytest -q repo_policy_sync/tests/test_reporting.py repo_policy_sync/tests/test_cli.py repo_policy_sync/tests/test_github.py
  • pre-commit run --files .github/workflows/repo-policy-sync.yml repo_policy_sync/docs/reference/cli.md

@AlexanderLanin AlexanderLanin changed the title fix(repo-policy-sync): use bot-compatible PR updates fix(repo-policy-sync): harden cross-repository apply Aug 31, 2026
f"- `{_markdown_cell(outcome.repository)}` / "
f"`{_markdown_cell(outcome.policy_id)}`: "
f"{_markdown_cell(_markdown_details(outcome))}"
f"{_markdown_cell(outcome.error or 'unknown error')}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

So anything else except policy_id and repository will now not be in the markdown cell anymore.
That is wanted?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

yes, intentional. too much noise. link to PR is there, no need to write here what was changed.

@AlexanderLanin AlexanderLanin changed the title fix(repo-policy-sync): harden cross-repository apply fix(repo-policy-sync): cross-repository apply Sep 1, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR updates repo-policy-sync to work with a cross-repository bot token that has repo scope by moving certain pull-request mutations off gh pr (GraphQL) and onto gh api REST endpoints, and tightens workflow behavior around bot identity and apply-mode prerequisites.

Changes:

  • Switch PR label application and PR body/title updates to gh api REST calls (avoiding read:org requirements).
  • Adjust markdown reporting to keep the “Details” section focused on errors only.
  • Update the GitHub Actions workflow to set a global bot git identity and fail fast in apply mode when SCORE_BOT_CLASSIC_PAT is missing; update tests accordingly.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
repo_policy_sync/src/github.py Use REST (gh api) to add PR labels and PATCH PR title/body; parse PR number from created URL.
repo_policy_sync/src/reporting.py Render markdown “Details” section from error outcomes only.
repo_policy_sync/tests/test_github.py Update expectations to reflect REST endpoints for labels and PR updates.
repo_policy_sync/tests/test_reporting.py Update test to assert only errors appear in markdown details.
.github/workflows/repo-policy-sync.yml Configure global bot author identity and require bot PAT in apply mode before running sync.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines 247 to 251
def _markdown_details_section(outcomes: tuple[RepositoryOutcome, ...]) -> list[str]:
detailed = tuple(
outcome for outcome in outcomes if _markdown_details(outcome) != "—"
)
"""Render error details without duplicating the policy pull-request list."""

detailed = tuple(outcome for outcome in outcomes if outcome.error)
if not detailed:
@AlexanderLanin
AlexanderLanin merged commit 38f1952 into main Sep 1, 2026
4 checks passed
@AlexanderLanin
AlexanderLanin deleted the bugfix/repo-policy-sync-apply-auth branch September 1, 2026 15:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants