[ci] r-configure comment job fails if PR branch is from a fork
Description
When the CI job that updates R-package/configure is triggered for a pull request from a fork, it fails with an error like the following:
Fetching the repository
/usr/bin/git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=5 origin +refs/heads/linear-threading:refs/remotes/origin/linear-threading
Error: fatal: couldn't find remote ref refs/heads/linear-threading
The process '/usr/bin/git' failed with exit code 128
Waiting 12 seconds before trying again
/usr/bin/git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=5 origin +refs/heads/linear-threading:refs/remotes/origin/linear-threading
Error: fatal: couldn't find remote ref refs/heads/linear-threading
The process '/usr/bin/git' failed with exit code 128
Waiting 19 seconds before trying again
/usr/bin/git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=5 origin +refs/heads/linear-threading:refs/remotes/origin/linear-threading
Error: fatal: couldn't find remote ref refs/heads/linear-threading
Error: The process '/usr/bin/git' failed with exit code 128
This error happens during the Checkout Repository step.
https://github.com/microsoft/LightGBM/blob/44fe591a60d7427d64997c37b22768a92c97c47b/.github/workflows/r_configure.yml#L23-L31
Reproducible example
First observed this on #5368, see https://github.com/microsoft/LightGBM/pull/5368#issuecomment-1183359780.
I believe commenting /gha run r-configure on any PR from a fork will result in this issue.
Environment info
Latest commit as of July 13, 2022 (https://github.com/microsoft/LightGBM/commit/44fe591a60d7427d64997c37b22768a92c97c47b).
Notes
I'm actually not sure if it's even possible to make this work for PRs from forks, since this job needs to push a commit to the PR branch. I don't know if it's actually permitted by GitHub for this repo's CI to push to a branch on a fork.
don't know if it's permitted....for this repo's CI to push to ... a fork
Here's one report where someone claims it's possible: https://github.com/actions/checkout/issues/455#issuecomment-1079943559.
Using the pull_request_target condition.
And according to https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#running-your-workflow-based-on-files-changed-in-a-pull-request-1, it seems like it might be possible to automatically re-generate configure on any PR modifying configure.ac.
Like this:
on:
pull_request_target:
types:
- opened
- edited
paths:
- 'R-package/configure.ac'
I don't know if it's actually permitted by GitHub for this repo's CI to push to a branch on a fork.
As of time of creating r_configure.yml it wasn't possible, as I remember.
Using the
pull_request_targetcondition.
Hmmm, sounds interesting...
I'm going to close this, so we can focus on other things.
It's easy enough to just regenerate the configure script with docker locally in the rare case where a PR from a fork requires it: https://github.com/microsoft/LightGBM/tree/master/R-package#changing-the-cran-package
This issue has been automatically locked since there has not been any recent activity since it was closed. To start a new related discussion, open a new issue at https://github.com/microsoft/LightGBM/issues including a reference to this.