Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion .env-example
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
export GITHUB_CLIENT_ID=
export GITHUB_CLIENT_SECRET=
export SESSION_SECRET=
export SESSION_SECRET=

# Main worlddriven GitHub App
export GITHUB_APP_ID=
export GITHUB_APP_PRIVATE_KEY=

# Worlddriven Migrate GitHub App (for repository transfers)
export MIGRATE_APP_ID=
export MIGRATE_APP_PRIVATE_KEY=

# Token for worlddrivenbot user (used for documentation repo operations)
export WORLDDRIVEN_GITHUB_TOKEN=
27 changes: 27 additions & 0 deletions src/helpers/githubApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,33 @@ export async function getInstallationOctokit(installationId) {
});
}

/**
* Get installation access token for a specific GitHub App
* Used for apps other than the main worlddriven app (e.g., migrate app)
* @param {number} installationId - Installation ID
* @param {string} appId - GitHub App ID
* @param {string} privateKey - GitHub App private key
* @returns {string} Installation access token
*/
export async function getInstallationAccessToken(
installationId,
appId,
privateKey
) {
if (!appId || !privateKey) {
throw new Error('App ID and private key are required');
}

const auth = createAppAuth({
appId,
privateKey,
installationId: parseInt(installationId),
});

const { token } = await auth({ type: 'installation' });
return token;
}

// GitHub App API functions
export async function getPullRequestsApp(installationId, owner, repo) {
const octokit = await getInstallationOctokit(installationId);
Expand Down
Loading