feat: Support for selecting a specific GitHub organization via a new GH_ORG environment variable - #1074
Open
renan-alm wants to merge 3 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Address the unmatched GH_ORG fallback and add dotenv as a direct dependency.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds organization-aware installation selection, improved full-sync initialization, dotenv loading, tests, and ignore rules.
Changes:
- Adds
GH_ORGhandling and installation-selection tests. - Updates full-sync environment loading and dependency metadata.
- Updates lockfile and local configuration ignores.
File summaries
| File | Summary |
|---|---|
test/unit/lib/syncInstallation.test.js |
Tests installation selection and repository ownership. |
test/unit/lib/env.test.js |
Tests GH_ORG environment handling. |
package.json |
Loads dotenv for full-sync; declare dotenv directly. |
package-lock.json |
Updates dependency resolutions. |
lib/env.js |
Exposes GH_ORG. |
index.js |
Selects installations using GH_ORG; unmatched organizations need explicit handling. |
full-sync.js |
Initializes Probot before syncing. |
.gitignore |
Ignores local Safe-Settings configuration paths. |
Review details
Suppressed comments (1)
index.js:235
- When
GH_ORGis set but is misspelled or the app is no longer installed for that organization, this expression silently selectsinstallations[0]instead. In a multi-installation setup, the full sync can therefore apply the admin configuration to an unintended organization; treat an unmatched explicit selector as an error or return without syncing instead of falling back.
const installation = (env.GH_ORG && installations.find(i => i.account.login === env.GH_ORG)) || installations[0]
- Files reviewed: 6/8 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| robot.log.debug(`installations: ${JSON.stringify(installations)}`) | ||
| if (installations.length > 0) { | ||
| const installation = installations[0] | ||
| const installation = (env.GH_ORG && installations.find(i => i.account.login === env.GH_ORG)) || installations[0] |
| "dev": "nodemon --inspect", | ||
| "start": "probot run ./index.js", | ||
| "full-sync": "node ./full-sync.js", | ||
| "full-sync": "node -r dotenv/config ./full-sync.js", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request adds support for selecting a specific GitHub organization installation via a new
GH_ORGenvironment variable, and updates the sync logic and tests accordingly. It also improves thefull-syncscript to support dotenv files and enhances test coverage for the new behavior.Organization selection improvements:
GH_ORGenvironment variable to filter and select the installation matching the specified organization, falling back to the first installation if not set or not found (index.js,lib/env.js). [1] [2] [3]GH_ORGis set, unset, or does not match any installation (test/unit/lib/env.test.js,test/unit/lib/syncInstallation.test.js). [1] [2] [3] [4]Sync script and environment loading:
full-syncnpm script to load environment variables from a.envfile usingdotenv(package.json).probot.load()is called infull-sync.jsfor proper initialization (full-sync.js).