Accessing secrets across forks

I have a main repository which contains a TOKEN in secrets, on a Pull request triggered action, that token is needed for authentication. To test this workflow, I tried sending PR from a branch within my main repo and it worked perfectly fine.
Next I forked my main repo, and then tried giving a PR to the main repo. In this case the actions failed!
I was trying various other things but got nowhere.
After a long time, it hit me that the secrets in main can’t be accessed through a PR run from an action triggered by a forked repo, coz maybe I thought the secrets is only accessible within the main repo.

So I went and created the same.secret in the forked repo as well, and re-run the jobs. Again it failed.
Now I am.completely clueless on how to successfully run that action on PR.

Can anyone explain how to find a work around this?,
Thanks in advance.

You’re going to need to use pull_request_target as your ‘on’ event.

There’s more info here: https://github.blog/2020-08-03-github-actions-improvements-for-fork-and-pull-request-workflows/#improvements-for-public-repository-forks

1 Like

This post was flagged by the community and is temporarily hidden.

Hey @kingthorin, I cant thank you enough for this, I’ve been scratching it all day long trying a lot of things. Thank you soo much :raised_hands: