坚持在 GitHub Actions 中使用 PAT(个人访问令牌)

Hos*_*lah 8 github github-actions

我有一个 GitHub 帐户。

我有一个私人组织。还有一些私人存储库。

我想在我的私人组织中为我的私人存储库定义一个操作。

private_org\private_rpo

我可以检查我的private_repo使用情况${{ github.token }}action/checkout@2

但是,我无法在该存储库的操作中查看我的其他存储库。

这是我的代码:

      - name: Get private_org/private_repo using actions/checkout@v2
        uses: actions/checkout@v2
        with:
          repository: private_org/private_repo
          token: ${{ github.token }}
          path: private_org/private_repo
          
      - name: Get private_org/private_repo_2 using actions/checkout@v2
        uses: actions/checkout@v2
        with:
          repository: private_org/private_repo_2
          token: ${{ github.pat }}
          path: private_org/private_repo_2 
Run Code Online (Sandbox Code Playgroud)

我在我的帐户(开发人员设置)中创建了一个 PAT,并patprivate_org/private_repo.

然而,action/checkout@2抱怨说:

运行 actions/checkout@v2
错误:需要输入但未提供:令牌

我应该如何解决这个问题?我应该在哪里定义我的pat秘密?如何在此私有存储库的操作中签出我的其他私有存储库?

Gui*_*urd 7

出现这个问题是因为你没有secrets在 github actions 上使用这种方式。

这是要更新的部分:

      - name: Get private_org/private_repo_2 using actions/checkout@v2
        uses: actions/checkout@v2
        with:
          repository: private_org/private_repo_2
          token: ${{ secrets.pat }} # use "secrets." instead of "github."
          path: private_org/private_repo_2 
Run Code Online (Sandbox Code Playgroud)