Skip to content

Commit 6ea5e9e

Browse files
authored
Merge pull request #47 from djmango/master
Add GITHUB_EXCLUDED_ORGS support for organization filtering
2 parents 8d29197 + 8d7ca8d commit 6ea5e9e

File tree

4 files changed

+20
-2
lines changed

4 files changed

+20
-2
lines changed

docker-compose.dev.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ services:
7070
# GitHub/Gitea Mirror Config
7171
- GITHUB_USERNAME=${GITHUB_USERNAME:-your-github-username}
7272
- GITHUB_TOKEN=${GITHUB_TOKEN:-your-github-token}
73+
- GITHUB_EXCLUDED_ORGS=${GITHUB_EXCLUDED_ORGS:-}
7374
- SKIP_FORKS=${SKIP_FORKS:-false}
7475
- PRIVATE_REPOSITORIES=${PRIVATE_REPOSITORIES:-false}
7576
- MIRROR_ISSUES=${MIRROR_ISSUES:-false}

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ services:
3535
# GitHub/Gitea Mirror Config
3636
- GITHUB_USERNAME=${GITHUB_USERNAME:-}
3737
- GITHUB_TOKEN=${GITHUB_TOKEN:-}
38+
- GITHUB_EXCLUDED_ORGS=${GITHUB_EXCLUDED_ORGS:-}
3839
- SKIP_FORKS=${SKIP_FORKS:-false}
3940
- PRIVATE_REPOSITORIES=${PRIVATE_REPOSITORIES:-false}
4041
- MIRROR_ISSUES=${MIRROR_ISSUES:-false}

docs/BUILD_GUIDE.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ JWT_SECRET=your-secret-here
9292
# GitHub Configuration
9393
GITHUB_TOKEN=ghp_...
9494
GITHUB_WEBHOOK_SECRET=...
95+
GITHUB_EXCLUDED_ORGS=org1,org2,org3 # Optional: Comma-separated list of organizations to exclude from sync
9596
9697
# Gitea Configuration
9798
GITEA_URL=https://your-gitea.com
@@ -202,4 +203,4 @@ Expected build times:
202203

203204
- Configure with [Configuration Guide](./CONFIGURATION.md)
204205
- Deploy with [Deployment Guide](./DEPLOYMENT.md)
205-
- Set up authentication with [SSO Guide](./SSO-OIDC-SETUP.md)
206+
- Set up authentication with [SSO Guide](./SSO-OIDC-SETUP.md)

src/lib/github.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,23 @@ export async function getGithubOrganizations({
172172
per_page: 100,
173173
});
174174

175+
// Get excluded organizations from environment variable
176+
const excludedOrgsEnv = process.env.GITHUB_EXCLUDED_ORGS;
177+
const excludedOrgs = excludedOrgsEnv
178+
? excludedOrgsEnv.split(',').map(org => org.trim().toLowerCase())
179+
: [];
180+
181+
// Filter out excluded organizations
182+
const filteredOrgs = orgs.filter(org => {
183+
if (excludedOrgs.includes(org.login.toLowerCase())) {
184+
console.log(`Skipping organization ${org.login} - excluded via GITHUB_EXCLUDED_ORGS environment variable`);
185+
return false;
186+
}
187+
return true;
188+
});
189+
175190
const organizations = await Promise.all(
176-
orgs.map(async (org) => {
191+
filteredOrgs.map(async (org) => {
177192
const [{ data: orgDetails }, { data: membership }] = await Promise.all([
178193
octokit.orgs.get({ org: org.login }),
179194
octokit.orgs.getMembershipForAuthenticatedUser({ org: org.login }),

0 commit comments

Comments
 (0)