chore: pkg.pr.new preview with label and comment
Description
issue comment events are not proper for pkg.pr.new since they do not pass the right information around the pull request we are running.
This causes few issues, like publishing vite versions from the last state of the main branch rather than the current PR branch.
What this PR does is it uses a workaround to leverage issue comment events. A comment would create a label, which would trigger the pull request labeled event and then it'd run the workflow.
After the run, it'd remove the label so it leaves the opportunity to other comments to cause a preview for the PR.
Run & review this pull request in StackBlitz Codeflow.
Why can't the action checkout the PR branch using a flow/logic like this? https://github.com/actions/checkout/issues/331
Why can't the action checkout the PR branch using a flow/logic like this? actions/checkout#331
I think that's what's brought up in https://github.com/stackblitz-labs/pkg.pr.new/issues/187 https://github.com/stackblitz-labs/pkg.pr.new/issues/200. It looks like there's some issue with webhook metadata, which we cannot workaround from action side.
I still don't quite understand the limitation. The issue_comment event has a way to get the PR number, pkg.pr.new should be able to grab the information / latest sha and publish from there. Many existing preview releases workflows that I've seen also don't really need a two step workflow to fix this. I think it's something pkg.pr.new should look deeper into instead of accepting this workaround IMO.
This is a limitation in pkg.pr.new! With relying on github webhook data, we won't need to deal with issues like spam or authentication. Authentication is just a hash of some unique (temporary) info provided by the webhook, and if it was replicated by the cli, then the publish is authenticated.
the issue_comment event in the webhook does not give us the information needed for generating that hash so we can later replicate it in a workflow run.
But in the soon future, we're thinking about a refactor where we'd stop relying on github so we'd support other environments, this will hopefully help us navigate the issue_comment problem.
I guess this is because of new workflow is coming from a fork repo
Or maybe because this my first ever PR in vite that it won't allow running any workflow.
Hey folks, I wonder if we can get this merged! Let me know if I should try anything before merging this.
And thanks for your help to keep exploring the diff approaches with us @Aslemammad!