Skip to content

Commit 290d29d

Browse files
authored
Merge pull request #18 from sicot-f/feature/ghe
Add GitHub Enterprise support
2 parents d6e4600 + 26ba507 commit 290d29d

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

.env-example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
GH_TOKEN=' '
22
TOPIC='inner-source'
33
ORGANIZATION=' '
4+
GH_ENTERPRISE_URL=' '

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ This project creates a `repos.json` that can be utilized by the [SAP InnerSource
1313
1. Fill out the `.env` file with a _token_ from a user that has access to the organization to scan (listed below). Tokens should have admin:org or read:org access.
1414
1. Fill out the `.env` file with the exact _topic_ name you are searching for
1515
1. Fill out the `.env` file with the exact _organization_ that you want to search in
16+
1. (Optional) Fill out the `.env` file with the exact _URL_ of the GitHub Enterprise that you want to search in. Keep empty if you want to search in the public `github.com`.
1617
1. Run `python3 ./crawler.py`, which will create a `repos.json` file containing the relevant metadata for the GitHub repos for the given _topic_
1718
1. Copy `repos.json` to your instance of the [SAP-InnerSource-Portal][SAP-InnerSource-Portal] and launch the portal as outlined in their installation instructions
1819

crawler.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@
1515
load_dotenv(dotenv_path)
1616

1717
# Auth to GitHub.com
18-
gh = github3.login(token=os.getenv("GH_TOKEN"))
18+
ghe = os.getenv("GH_ENTERPRISE_URL", default="").strip()
19+
if ghe:
20+
gh = github3.github.GitHubEnterprise(ghe, token=os.getenv("GH_TOKEN"))
21+
else:
22+
gh = github3.login(token=os.getenv("GH_TOKEN"))
1923

2024
# Set the topic
2125
topic = os.getenv("TOPIC")

0 commit comments

Comments
 (0)