Skip to main content

GitHub 所在位置

GitHub 集成支持从 github.com 或 GitHub Enterprise 加载目录实体。 实体可添加到静态目录配置目录-导入插件,或所发现用户和用户组也可以通过从一个组织加载.

配置

要使用此集成,请将配置添加到根目录中app-config.yaml:

integrations:
github:
- host: github.com
token: ${GITHUB_TOKEN}
- host: ghe.example.net
apiBaseUrl: https://ghe.example.net/api/v3
rawBaseUrl: https://ghe.example.net/raw
token: ${GHE_TOKEN}

注意:为方便起见,GitHub 公共提供程序会在启动时自动添加,因此只需在提供 token 时列出即可。

正下方github键是一个提供商配置列表,你可以在这里列出你希望从其中获取数据的各种 GitHub 兼容提供商。 每个条目都是一个最多包含四个元素的结构:

  • host (optional): The host of the location target that you want to match on. The default host is github.com. * token (optional): An authentication token as expected by GitHub. If supplied, it will be passed along with all calls to this provider, both API and raw. If it is not supplied, anonymous access will be used. * apiBaseUrl (optional): If you want to communicate using the APIv3 method with this provider, specify the base URL for its endpoint here, with no trailing slash. Specifically when the target is GitHub, you can leave it out to be inferred automatically. For a GitHub Enterprise installation, it is commonly at https://api.<host> or https://<host>/api/v3. * rawBaseUrl (optional): If you want to communicate using the raw HTTP method with this provider, specify the base URL for its endpoint here, with no trailing slash. Specifically when the target is public GitHub, you can leave it out to be inferred automatically. For a GitHub Enterprise installation, it is commonly at `https:///

您需要提供apiBaseUrlrawBaseUrl或两者都有(公共 GitHub 除外,我们可以推断出它们)。apiBaseUrl如果有一个token否则rawBaseUrl将是首选。

代币范围

在 GitHub 上创建个人访问令牌时,必须选择作用域来定义令牌的访问级别。 所需作用域因集成的用途而异:

  • 读取软件组件: - repo * 读取组织数据: - read:org - read:user - user:email * 发布软件模板: - repo - workflow (如果模板包含 GitHub 工作流程)

使用 GitHub 应用程序进行身份验证

另外,对于 GitHub 组织,Backstage 可以使用 GitHub Apps 进行后端身份验证。 这具有更高的速率限制和更清晰的授权模式。 参见github-apps了解如何设置。