Skip to content

refactor: migrate GitOps PR + chore-issue flows to go-github (#458) - #463

Merged
antoinetoussaint-byte merged 4 commits into
mainfrom
issue-458-migrate-gitops-pr-chore-issue-flows-from-gh
Aug 23, 2026
Merged

refactor: migrate GitOps PR + chore-issue flows to go-github (#458)#463
antoinetoussaint-byte merged 4 commits into
mainfrom
issue-458-migrate-gitops-pr-chore-issue-flows-from-gh

Conversation

@antoinetoussaint-byte

@antoinetoussaint-byteantoinetoussaint-byte commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Closes#458.

Summary

  • Replaces the gh pr list/create/edit + PR-view verification (pkg/gitops/publish.go) and gh issue create (cmd/status/release.go) shell-outs with github.com/google/go-github/v89 REST calls, so those PR/issue operations no longer depend on the gh binary and share one client's error/rate-limit behavior.
  • Extracts the client/token plumbing that already lived in cmd/agents/versions.go into a shared pkg/github (NewClient + Token), now reused by cmd/agents, pkg/gitops, and cmd/status — not a third copy. NewClient honors GITHUB_API_URL (GitHub Actions / Enterprise), which also gives tests a clean HTTP seam.
  • Genuine git operations (branch pushes, clones) stay on the gitCommand git binary and are untouched.

Deviation from the issue: observe.go stays on gh

The issue lists observeReview's gh pr view (pkg/gitops/observe.go) as a migration target. It is deliberately not migrated.

observeReview gates deploy authorization on GitHub's reviewDecision, a GraphQL-computed field that folds in branch-protection required-approval counts and CODEOWNERS. PullRequests.Get (REST) does not expose it, and deriving it from the REST review list (">=1 approval, no outstanding change request") silently weakens the gate: a promotion PR with a single non-required approval, merged via admin/maintainer bypass, would derive APPROVED and pass a gate that gh pr view --json reviewDecision correctly rejects. Since a faithful REST equivalent does not exist, this path keeps gh (consistent with the #460 umbrella decision). The remaining gh PR/issue shell-outs are eliminated.

Test plan

  • go build ./...
  • go vet ./pkg/github/... ./pkg/gitops/... ./cmd/agents/... ./cmd/status/...
  • go test ./pkg/github/... ./pkg/gitops/... ./cmd/agents/... ./cmd/status/...
  • pkg/github client tests (auth header, unauthenticated, GITHUB_API_URL endpoint)
  • PR create path + edit/update path (openOrUpdatePullRequest: existing PR edited, head-commit drift rejected) driven by an httptest GitHub server instead of a fake gh binary
  • cmd/status chore-issue creation + remote parsing tests

🤖 Generated with Claude Code

…458)
Replace the `gh pr list/create/edit/view` and `gh issue create` shell-outs
with go-github REST calls, and extract a shared `pkg/github` client/token
helper reused by cmd/agents, pkg/gitops and cmd/status.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The review-decision gate in observeReview was migrated to a REST-derived
approval check. GitHub's reviewDecision is a GraphQL-computed field that
folds in branch-protection required-approval counts and CODEOWNERS; a REST
">=1 approval, no change request" derivation cannot see those. A promotion
PR with a single non-required approval, merged via admin/maintainer bypass,
would derive APPROVED and pass the deploy-authorization gate that the old
`gh pr view --json reviewDecision` correctly rejected. Revert observe.go to
gh — reviewDecision has no faithful REST equivalent.
Add tests for the PR update path in openOrUpdatePullRequest (existing open
promotion is edited; head-commit drift is rejected), which the go-github
migration previously left uncovered.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
golangci-lint flagged two new issues from the go-github migration:
- gosec G702 on the `git remote get-url` call in agentRepository: git runs
with fixed subcommands and a scanned filesystem path as an argument (no
shell), so annotate with //nolint:gosec matching the pkg/librarystore
precedent.
- govet shadow: the PullRequests.Edit error redeclared the outer `err`;
rename it to editErr.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ops-pr-chore-issue-flows-from-gh
# Conflicts:
#	cmd/agents/versions.go
Sign up for freeto 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.

Migrate GitOps PR + chore-issue flows from gh CLI to go-github API

1 participant

@antoinetoussaint-byte