Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide Cloudflare (or other) preview on forked PRs #79

Open
rfay opened this issue Aug 15, 2023 · 2 comments
Open

Provide Cloudflare (or other) preview on forked PRs #79

rfay opened this issue Aug 15, 2023 · 2 comments

Comments

@rfay
Copy link
Member

rfay commented Aug 15, 2023

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.

@bmartinez287
Copy link
Collaborator

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.

@gilzow
Copy link
Collaborator

gilzow commented Oct 31, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants