我需要在 GitHub Actions 工作流程中 checkout 一个私有(private)仓库。我正在使用结帐操作,并遵循其 README :
现在,当我只执行以下操作时,它不起作用:
- name: Checkout
uses: actions/checkout@v2
with:
token: ${{secrets.MY_TOKEN}}
好像我没有配置git
以允许它使用 token 。我的问题是:我应该或如何配置 git config
在上述步骤中使用 token ?谢谢。
编辑:私有(private)仓库是主仓库的依赖。两个 repos 都是 Rust 程序,使用 Cargo。因此,我尝试使用相同的服务帐户首先 check out 主存储库。然后 cargo 将检查私有(private) repo 。
编辑 2:对不起,这是一个不好的问题。我不知道我在做什么。请忽略。
最佳答案
根据the actions/checkout documentation ,您需要添加 repository input
以及私有(private)存储库:
在您的工作流程中,它应该类似于以下内容 .yml
文件:
- name: Checkout
uses: actions/checkout@v2
with:
path: main
- name: Checkout private repo
uses: actions/checkout@v2
with:
repository: your-private/repo_name
token: ${{ secrets.MY_TOKEN }}
您不需要为 git
配置任何其他内容除非您需要特定的
path
,在这种情况下,您还需要将其作为输入通知:- name: Checkout private repo
uses: actions/checkout@v2
with:
repository: your-private/repo_name
token: ${{ secrets.MY_TOKEN }}
path: path-to-directory
关于github-actions - 如何配置 git 以在 GitHub 操作结帐中使用 PAT token ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67030607/