github-actionsgit-clone

Access another repo in organization in github action


I have a github action yml file that runs in a repo in an organization, in this file I need information that is in another repo inside the same organization. How can I clone this repo inside the yml file, so I can access the information there? I have tried

- name: Checkout configs
      uses: actions/checkout@v3
      with:

        repository: org/configs
        token: ${{ secrets.GH_PAT }} 
        path: configs

Im not sure if this secrets.GH_PAT need to be created or if this is something stored in the org or repo. The error I get that it cant find the token. And if I change the token to: token: ${{ secrets.GH_PAT || github.token }} it cant find the repo.


Solution

  • The answer was that a admin needed to create a token in the org.

    - name: Checkout configs
          uses: actions/checkout@v3
          with:
            repository: org/configs
            token: ${{ secrets.TOKEN_CREATED_BY_ADMIN }}
            path: configs
            ref: master