Search code examples
githubgithub-actions

Stuck at using PAT (Personal Access Token) in GitHub Actions


I have one GitHub account.

I have one private organization. And a couple of private repositories.

I want to define an action for my private repository, in my private organization.

private_org\private_rpo

And I can checkout my private_repo using ${{ github.token }} and action/checkout@2.

However, I'm stuck at checking out my other repo in this repo's action.

Here's my code:

      - 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 

I have created a PAT in my accounts (developer settings), and I have defined pat as a secret in private_org/private_repo.

However, action/checkout@2 complains that:

Run actions/checkout@v2
Error: Input required and not supplied: token

How should I solve this? Where should I define my pat secrect? How can I checkout my other private repository in this private repository's action?


Solution

  • This problem occured because you don't use secrets that way on github actions.

    Here is the part to update:

          - 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