how can I extract repo A's GITHUB_TOKEN in repo B?

208 Views Asked by At

Is there a way to extract GITHUB_TOKEN belongs to one repo to another repo in the same organization?

I am working on fetching the GitHub limit rate data for repo A by calling the GitHub API. But I cannot simply implement the workflow in that repo A since the workflow needs to be triggered too frequently. I have to put the workflow in repo B, and call the GitHub api by using the GITHUB_TOKEN of repo A. However, I do not know how to use the repo A's GITHUB_TOKEN in repo B. Is there a way to do this?

I have tried to call the GITHUB_TOKEN in repo B, but it has the different usage with the repo A. Does anyone have experience about it?

Thx so much for your help!

1

There are 1 best solutions below

0
On

For what you describe github actions secrets sounds like the best fit, you should get the token from repo A and add it as a secret REPO_A_KEY in repo B's https://github.com/{youracc}/{repoBname}/settings/secrets/actions.

Then in a github action you access the variable like ${{secrets.REPO_A_KEY}}