Skip to content

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
github-community-projects:main-enterprisefrom
renan-org:main-enterprise
Open

feat: Support for selecting a specific GitHub organization via a new GH_ORG environment variable#1074
renan-alm wants to merge 3 commits into
github-community-projects:main-enterprisefrom
renan-org:main-enterprise

Conversation

@renan-alm

@renan-alm renan-alm commented Sep 10, 2026

Copy link
Copy Markdown

This pull request adds support for selecting a specific GitHub organization installation via a new GH_ORG environment variable, and updates the sync logic and tests accordingly. It also improves the full-sync script to support dotenv files and enhances test coverage for the new behavior.

Organization selection improvements:

  • Added support for a GH_ORG environment 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]
  • Updated tests to verify correct behavior when GH_ORG is 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:

  • Modified the full-sync npm script to load environment variables from a .env file using dotenv (package.json).
  • Ensured probot.load() is called in full-sync.js for proper initialization (full-sync.js).

Copilot AI lite review requested due to automatic review settings September 10, 2026 13:40
@renan-alm renan-alm changed the title Pull Safe-Settings feat: Support for selecting a specific GitHub organization via a new GH_ORG environment variable Sep 10, 2026

Copilot AI left a comment

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.

🟡 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_ORG handling 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_ORG is set but is misspelled or the app is no longer installed for that organization, this expression silently selects installations[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.

Comment thread index.js
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]
Comment thread package.json
"dev": "nodemon --inspect",
"start": "probot run ./index.js",
"full-sync": "node ./full-sync.js",
"full-sync": "node -r dotenv/config ./full-sync.js",
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.

2 participants