【问题标题】:Install private repository from a private repository of the same organization从同一组织的私有仓库安装私有仓库
【发布时间】:2020-09-23 06:42:28
【问题描述】:

我在同一个组织中有两个私有存储库,比如存储库 A 和 B,它们都是 python 包。我有一个“GitHub Actions 工作流程”来测试每个 PR 的存储库 B。但是,存储库 B 依赖于存储库 A,因此我需要安装它。
我尝试关注this GitHub document,但是,它特别指出

GITHUB_TOKEN cannot install packages from any private repository besides the repository where the action runs.

我该如何实施这个安装?

【问题讨论】:

    标签: git github workflow github-actions


    【解决方案1】:

    这只是意味着您不能使用预定义的GITHUB_TOKEN。使用read:packages 范围创建个人访问令牌 (PAT),并将其作为机密添加到您的存储库中。

    如果您需要的令牌需要 GITHUB_TOKEN 中不可用的权限,您可以创建个人访问令牌并将其设置为您的存储库中的机密:

    1. 使用或创建具有该存储库适当权限的令牌。如需更多信息,请参阅“Creating a personal access token”。
    2. 将令牌作为机密添加到工作流的存储库中,并使用 ${{ secrets.SECRET_NAME }} 语法引用它。如需更多信息,请参阅“Creating and using encrypted secrets”。

    来源:https://docs.github.com/en/free-pro-team@latest/actions/reference/authentication-in-a-workflow#permissions-for-the-github_token

    【讨论】:

    • 忘了回答我自己的问题,确实这是唯一可行的方法。 Github 建议在文档中拥有一个“机器人”用户,该用户可用于执行此操作。
    猜你喜欢
    • 2019-04-03
    • 1970-01-01
    • 1970-01-01
    • 2021-11-04
    • 2022-08-20
    • 1970-01-01
    • 2023-03-20
    • 1970-01-01
    相关资源
    最近更新 更多