Last active
February 25, 2023 18:51
-
-
Save padupe/b89228a1668f6790b73c93109cd4d2ea to your computer and use it in GitHub Desktop.
[Backstage] Getting Started GitHub Integration on a Backstage Instance
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// packages/backend/src/plugins/catalog.ts | |
import { CatalogBuilder } from '@backstage/plugin-catalog-backend'; | |
import { ScaffolderEntitiesProcessor } from '@backstage/plugin-scaffolder-backend'; | |
import { Router } from 'express'; | |
import { PluginEnvironment } from '../types'; | |
import { GithubEntityProvider, GithubOrgEntityProvider } from '@backstage/plugin-catalog-backend-module-github'; | |
export default async function createPlugin( | |
env: PluginEnvironment, | |
): Promise<Router> { | |
const builder = await CatalogBuilder.create(env); | |
builder.addEntityProvider( | |
/* | |
Provider responsável por "bater" em todos os repositórios | |
frequency: refere-se ao intervalo entre as atualizações | |
timeout: refere-se ao tempo MÁXIMO que uma entidade será reprocessada em caso de falha | |
*/ | |
GithubEntityProvider.fromConfig(env.config, { | |
logger: env.logger, | |
schedule: env.scheduler.createScheduledTaskRunner({ | |
frequency: { minutes: 35 }, | |
timeout: { minutes: 30 } | |
}) | |
}), | |
/* | |
Provider responsável por "importar" dados da Organização (Usuários, Times, etc) | |
frequency: refere-se ao intervalo entre as atualizações | |
timeout: refere-se ao tempo MÁXIMO que uma entidade será reprocessada em caso de falha | |
*/ | |
GithubOrgEntityProvider.fromConfig(env.config, { | |
id: 'Tutorial-Backstage', | |
orgUrl: 'https://github.com/Tutorial-Backstage', | |
logger: env.logger, | |
schedule: env.scheduler.createScheduledTaskRunner({ | |
frequency: { minutes: 60 }, | |
timeout: { minutes: 15 }, | |
}), | |
}), | |
); | |
builder.addProcessor(new ScaffolderEntitiesProcessor()); | |
const { processingEngine, router } = await builder.build(); | |
await processingEngine.start(); | |
return router; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment