I have a workflow that’s using github/checkout and I’m trying to use a Github Application so I can give it higher permissions when it’s pushing to a repository. When I added that token in the usual way:
- uses: actions/checkout@v3
with:
token: ${{ env.GITHUB_TOKEN }}
it failed with
could not read Username for ‘https://github.com’: terminal prompts disabled
which I think just means the token is invalid, but I’m not 100% sure. Is this possible? How should it be done?
When using a GitHub Application token for authentication in your workflow, you need to make a few adjustments to the checkout step. The
actions/checkout
action does not support using thetoken
parameter with a GitHub Application token directly.To authenticate with a GitHub Application token, you can use the
@actions/checkout
action with a specific version (v2.3.4 or higher) that supports therepository
andref
parameters. Here’s an example of how you can modify your workflow:In the above example, replace
owner/repo
with the actual repository you want to check out.By specifying the
token
parameter as${{ secrets.GITHUB_TOKEN }}
, it will automatically use the token provided by GitHub for the workflow, which should have sufficient permissions for most operations.Make sure to use the
@v2.3.4
version or a higher version that supports therepository
andref
parameters for using the GitHub Application token in the checkout action.Remember to grant the necessary permissions to your GitHub Application to perform the required actions on the repository. You can manage the application’s permissions in the repository’s settings under “Installed GitHub Apps.”
With these modifications, you should be able to use a GitHub Application token for higher permissions during the checkout and subsequent steps in your workflow.