xt0rted / pull-request-comment-branch

A GitHub Action to get the head ref and sha of a pull request comment

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Compatability with forks

neuronull opened this issue · comments

We're using this helpful GHA in CI at https://github.com/vectordotdev/vector/

One limitation we've ran into is that the when we trigger a workflow run that uses this GHA, but the PR was opened from a fork off the main repo, the git fetch operation fails.

Presumably this is because the GHA is looking at the main repo for the branch in question.

Example output:

Fetching the repository
  /usr/bin/git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 origin +refs/heads/readd-log-to-metric-feat*:refs/remotes/origin/readd-log-to-metric-feat* +refs/tags/readd-log-to-metric-feat*:refs/tags/readd-log-to-metric-feat*
  The process '/usr/bin/git' failed with exit code 1
  Waiting 11 seconds before trying again
  /usr/bin/git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 origin +refs/heads/readd-log-to-metric-feat*:refs/remotes/origin/readd-log-to-metric-feat* +refs/tags/readd-log-to-metric-feat*:refs/tags/readd-log-to-metric-feat*
  The process '/usr/bin/git' failed with exit code 1
  Waiting 13 seconds before trying again
  /usr/bin/git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 origin +refs/heads/readd-log-to-metric-feat*:refs/remotes/origin/readd-log-to-metric-feat* +refs/tags/readd-log-to-metric-feat*:refs/tags/readd-log-to-metric-feat*
  Error: The process '/usr/bin/git' failed with exit code 1

It would be very useful to be able to use this GHA with PRs that are opened from forks! Thanks!

Ehh hitting this issue as well 🥲

I think this would be fixed by #356 which would expose the repository as an output to be used with the checkout action.

If it's useful for anyone else, I've created a fork for this purpose: https://github.com/alessbell/pull-request-comment-branch