xt0rted / pull-request-comment-branch

A GitHub Action to get the head ref and sha of a pull request comment
MIT License
87 stars 30 forks source link

Compatability with forks #385

Open neuronull opened 1 year ago

neuronull commented 1 year ago

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!

vwxyzjn commented 1 year ago

Ehh hitting this issue as well 🥲

jszwedko commented 8 months ago

I think this would be fixed by https://github.com/xt0rted/pull-request-comment-branch/pull/356 which would expose the repository as an output to be used with the checkout action.

alessbell commented 6 months ago

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