oprypin / nightly.link

Downloads the latest "nightly" build/artifact from a continuous testing workflow
https://nightly.link/
GNU Affero General Public License v3.0
638 stars 20 forks source link

PR Commenting bot doesn't work with forked repo's creating a PR #37

Open Baklap4 opened 2 years ago

Baklap4 commented 2 years ago

Within Performous we're trying to use the PR Commenting. All works fine when the main repo creates a branch and opens a PR. (can be seen here: https://github.com/performous/performous/pull/725)

However upon opening a PR from a forked repo branch into the main master (can be seen here: https://github.com/performous/performous/pull/726)we're getting the error:

pr_comment This workflow doesn't match any pull requests!

These are the workflows within our master branch: https://github.com/performous/performous/tree/master/.github/workflows

ooshlablu commented 2 years ago

To add a bit more information: github.event.workflow_run.pull_requests returns nothing when a PR is created from a fork, but returns everything you would expect when a PR is made internally to the repo. Unfortunately, I don't think there is really anything that can be done at the moment. This is either a bug in GitHub Actions or unsupported activity. I have found a workaround using the issues search API. I will post a PR with my updates in a little while.

oprypin commented 2 years ago

Seeing as your PR changes to search API and this commit seems to change away from search API https://github.com/oprypin/nightly.link/commit/99348f45f0bad7dc54bff923a98bd8a901800e6c -perhaps it's enough to revert it. Could you please try the old version of the script and see if that works just as well as in your PR?

oprypin commented 2 years ago

Forgot to post the actual old version of the script that I mention. Here it is. https://github.com/oprypin/nightly.link/blob/4e83d1452dd1bf350ebe1a3910e395e6cf447fdf/.github/workflows/pr-comment.yml

ooshlablu commented 2 years ago

I tried the old version in my repo https://github.com/ooshlablu/performous It failed with the error: No matching pull request found

rfay commented 2 years ago

I certainly am having this problem. Can it have anything to do with the recent update of actions/github-script to v6?

oprypin commented 2 years ago

You tell me ¯\_(ツ)_/¯ Just try the version before that https://github.com/oprypin/nightly.link/blob/4e83d1452dd1bf350ebe1a3910e395e6cf447fdf/.github/workflows/pr-comment.yml

rfay commented 2 years ago

Here's the version you suggest, working fine with a PR:

https://github.com/drud/junk-test-pr-comment/pull/2

oprypin commented 2 years ago

OK so in the meantime you can simply use that if it works better. There's no requirement that the script currently merged in the main branch here needs to be used, there are no permanent references to it. I don't know when I'll get around to considering this issue.

rfay commented 2 years ago

In the test repo I did try out the new/current version just to verify; it fails as described here. But the old version, https://github.com/oprypin/nightly.link/blob/4e83d1452dd1bf350ebe1a3910e395e6cf447fdf/.github/workflows/pr-comment.yml works OK.

white-gecko commented 1 year ago

For me, just reverting to https://github.com/oprypin/nightly.link/blob/4e83d1452dd1bf350ebe1a3910e395e6cf447fdf/.github/workflows/pr-comment.yml did not work, I got:

…
TypeError: Cannot read properties of undefined (reading 'list')
Error: Unhandled error: TypeError: Cannot read properties of undefined (reading 'list')
    at eval (eval at callAsyncFunction (/home/runner/work/_actions/actions/github-script/v6/dist/index.js:15143:16), <anonymous>:8:36)
    at eval (eval at callAsyncFunction (/home/runner/work/_actions/actions/github-script/v6/dist/index.js:15143:16), <anonymous>:16:3)
    at callAsyncFunction (/home/runner/work/_actions/actions/github-script/v6/dist/index.js:15144:12)
    at main (/home/runner/work/_actions/actions/github-script/v6/dist/index.js:15236:26)
    at /home/runner/work/_actions/actions/github-script/v6/dist/index.js:15217:1
    at /home/runner/work/_actions/actions/github-script/v6/dist/index.js:15268:3
    at Object.<anonymous> (/home/runner/work/_actions/actions/github-script/v6/dist/index.js:15271:12)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)

did anyone find a stable solution that works with the current API?

white-gecko commented 1 year ago

This might be a working option: https://github.com/HarbourMasters/Shipwright/blob/071a2d0418d6fb7464a1ddccd2b647683da38eff/.github/workflows/pr-artifacts.yml

white-gecko commented 1 year ago

This one works for me now: https://github.com/AKSW/submission.d2r2.aksw.org/blob/680c23f975f51f06e6a4b7e212b56abfeca8f800/.github/workflows/pr-comment.yml