Open rfay opened 10 months ago
https://developers.cloudflare.com/pages/platform/known-issues "Commits/PRs from forked repositories will not create a preview. Support for this will come in the future." I wonder what worked around they used for it.
It's a technique, but I'm not sure I would recommend it.
Bulk of the work is in this workflow: https://github.com/platformsh/platformsh-docs/blob/main/.github/workflows/build-from-fork.yaml
Essentially, for PRs from forks, we create a duplicate branch in the base repository from the fork's branch once the PR has been labeled as build-fork
. We then push the duplicate to platform.sh and activate it as an environment. from then on, pushes to the PR are forced-pushed onto the cloned copy of the branch.
Once the PR is accepted, we have to handle deactivation and deletion of the cloned branch : https://github.com/platformsh/platformsh-docs/blob/main/.github/workflows/manage-environment.yaml#L72
It works but not without issues. Since we need to do things like add labels and comments, we have to run these workflows using the pull_request_target
event instead of the pull_request
event. This is potentially very dangerous. I'm not exactly happy with this setup as we have it but it's the best given our constraints.
In today's contributor training we noted that Cloudflare previews aren't available on forked PRs. @chadcarlson and @gilzow mentioned that they have a technique that was used for forked PRs on Platform.sh docs.