Skip to content

Commit

Permalink
Use generic Octokit for non GitHub App installed owners
Browse files Browse the repository at this point in the history
  • Loading branch information
dexter-sim committed Oct 26, 2024
1 parent ce73b4b commit 1615ac1
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions backend/jobs/publicGithubJob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,19 @@ const fetchPublicRepoData = async () => {
const getPublicCourseData = async (course: any) => {
if (!course.gitHubRepoLinks || course.gitHubRepoLinks.length === 0) return;

const app: App = getGitHubApp();
const genericOctokit = app.octokit; // Use a generic octokit instance

for (const repoUrl of course.gitHubRepoLinks) {
const urlParts = repoUrl.split('/');
const owner = urlParts[3]; // Get the 'owner' part of the URL
const repo = urlParts[4]; // Get the 'repo' part of the URL

const installationId = await checkAppInstalled(owner);
const app: App = getGitHubApp();

const octokit = installationId
? await app.getInstallationOctokit(installationId)
: genericOctokit;
: new Octokit();

try {
// Fetch repository data using public Octokit instance
const repoData = await octokit.rest.repos.get({
owner,
repo,
Expand Down

0 comments on commit 1615ac1

Please sign in to comment.