GITHUB_TOKEN 仅适用于触发存储库。如果您需要访问其他存储库或其他帐户中的任何资源,则需要将范围更广的令牌传递给结帐步骤。这可以是 GitHub 应用令牌、个人访问令牌等。
将令牌存储在 Secrets/Actions 中并将其传递给结帐任务的令牌参数。
或者,您可以通过“ssh-key”参数传入 ssh 密钥。
- uses: actions/checkout@v2
with:
# Repository name with owner. For example, actions/checkout
# Default: ${{ github.repository }}
repository: ''
# Personal access token (PAT) used to fetch the repository. The PAT is configured
# with the local git config, which enables your scripts to run authenticated git
# commands. The post-job step removes the PAT.
#
# We recommend using a service account with the least permissions necessary. Also
# when generating a new PAT, select the least scopes necessary.
#
# [Learn more about creating and using encrypted secrets](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets)
#
# Default: ${{ github.token }}
token: ''
# SSH key used to fetch the repository. The SSH key is configured with the local
# git config, which enables your scripts to run authenticated git commands. The
# post-job step removes the SSH key.
#
# We recommend using a service account with the least permissions necessary.
#
# [Learn more about creating and using encrypted secrets](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets)
ssh-key: ''
这同样适用于通过 API 或 GitHub CLI 调用其他存储库中的资源。