Skip to content

Repository picker dropdown#2

Open
retlehs wants to merge 1 commit into
jakemgold:mainfrom
retlehs:github-repo-picker
Open

Repository picker dropdown#2
retlehs wants to merge 1 commit into
jakemgold:mainfrom
retlehs:github-repo-picker

Conversation

@retlehs
Copy link
Copy Markdown

@retlehs retlehs commented May 3, 2026

Screenshot 2026-05-03 at 10 05 16 AM

Summary

Adds a repository dropdown to the Repositories tab so you can pick from your accessible GitHub repos instead of typing owner/repo by hand. The dropdown appears whenever a Personal Access Token is configured. If no PAT is set (or the API call fails), the original free-text input is kept as a fallback:

image

What's new

  • Repository dropdown grouped by owner, populated from the GitHub API
  • Repos already being tracked are filtered out of the dropdown
  • New "Refresh repository list" button on the Settings tab (the list is otherwise cached for 5 minutes)
  • The display name of newly added repos uses the raw repo slug (e.g. trellis-cli) rather than a title-cased derivation (Trellis Cli)
  • README documents the recommended fine-grained PAT setup

Setting the PAT outside the database

For sites that prefer not to store secrets in wp_options, the PAT can also be supplied via:

  • A PHP constant GITHUB_RELEASE_POSTS_PAT defined in wp-config.php
  • An environment variable of the same name

Resolution order is constant → environment variable → encrypted database value. When the PAT is set externally, the Settings field shows the masked placeholder and is disabled.

Known limitation / possible follow-up

GitHub's /user/repos endpoint returns every repository the user behind the token can see, not just the ones a fine-grained PAT was scoped to. There's no GitHub API a fine-grained PAT can call to get its own selected-repos list. So the dropdown can be noisier than ideal for users with access to many repositories.

A natural follow-up is GitHub App support, which exposes a true allowlist via /installation/repositories (this is the model Cloudflare and similar services use). The auth path in this PR is structured to make adding that straightforward without breaking existing PAT installs.

…/ constant overrides

The Repositories tab swaps the free-text "owner/repo" input for a
<select> populated from /user/repos when a PAT is configured, grouped
by owner and filtered to repos not already tracked. The free-text
input remains as a fallback when no PAT is set or the API call errors.

The PAT can now be supplied via the GITHUB_RELEASE_POSTS_PAT PHP
constant or environment variable in addition to the existing encrypted
DB option. Resolution order is constant > env > DB. When supplied
externally the Settings field is disabled so accidental form submits
can't shadow the value.

Other small changes:

- New "Refresh repository list" button on the Settings tab busts the
  5-minute repo-list cache via a new POST /ghrp/v1/repos/refresh
  endpoint. Mirrors the existing Send Test Email pattern.
- New repos store the raw repo slug as the display name instead of
  the title-cased derivation, since the slug is what users recognize.
- README documents the recommended fine-grained PAT setup.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

1 participant