Merge pull request #23292 from RedlineTriad/export-get-octokit-options
feat: export `getOctokitOptions` for easier Octokit config reuse
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-scaffolder-backend-module-github': patch
|
||||
---
|
||||
|
||||
Export `getOctokitOptions` for easy re-use of Octokit configuration handling
|
||||
@@ -9,6 +9,7 @@ import { createPullRequest } from 'octokit-plugin-create-pull-request';
|
||||
import { GithubCredentialsProvider } from '@backstage/integration';
|
||||
import { JsonObject } from '@backstage/types';
|
||||
import { Octokit } from 'octokit';
|
||||
import { OctokitOptions } from '@octokit/core/dist-types/types';
|
||||
import { ScmIntegrationRegistry } from '@backstage/integration';
|
||||
import { ScmIntegrations } from '@backstage/integration';
|
||||
import { TemplateAction } from '@backstage/plugin-scaffolder-node';
|
||||
@@ -392,6 +393,14 @@ export const createPublishGithubPullRequestAction: (
|
||||
JsonObject
|
||||
>;
|
||||
|
||||
// @public
|
||||
export function getOctokitOptions(options: {
|
||||
integrations: ScmIntegrationRegistry;
|
||||
credentialsProvider?: GithubCredentialsProvider;
|
||||
token?: string;
|
||||
repoUrl: string;
|
||||
}): Promise<OctokitOptions>;
|
||||
|
||||
// @public
|
||||
const githubModule: () => BackendFeature;
|
||||
export default githubModule;
|
||||
|
||||
@@ -39,6 +39,11 @@ import {
|
||||
|
||||
const DEFAULT_TIMEOUT_MS = 60_000;
|
||||
|
||||
/**
|
||||
* Helper for generating octokit configuration options for given repoUrl.
|
||||
* If no token is provided, it will attempt to get a token from the credentials provider.
|
||||
* @public
|
||||
*/
|
||||
export async function getOctokitOptions(options: {
|
||||
integrations: ScmIntegrationRegistry;
|
||||
credentialsProvider?: GithubCredentialsProvider;
|
||||
|
||||
@@ -28,3 +28,5 @@ export {
|
||||
} from './githubPullRequest';
|
||||
export { createPublishGithubAction } from './github';
|
||||
export { createGithubAutolinksAction } from './githubAutolinks';
|
||||
|
||||
export { getOctokitOptions } from './helpers';
|
||||
|
||||
Reference in New Issue
Block a user