How to access the payload for a pull request?

I need to access the head repo owner and repo name in case of pull requests from forked repos. I can make a network call to access these details but am unable to export these to the environment using code.

I am creating an intermediary step in the pipeline which does integration test by merging the pull request in a new branch and thus need to access the owner name and repo name (which could be different in case the forked repo is renamed).