Get Previews for PRs from forks
Is there any way to get previews of PRs from fork if I am using cloudflare pages?
Like the way vercel supports.
Thank you !!
#pages-help
14 Replies
Pretty sure it is not currently possible to.
hey! if you're willing to work with GH actions, then I've forked the official pages-action for this exact purpose: https://github.com/AdrianGonz97/refined-cf-pages-action
as well as added a couple of extra features, like deployment summaries (demoed here)
Can I trust on third party github actions?
Like for this I need to remove my official cloudflare github app.
@CokaKoala Is there way I write my workflow for getting preview of PRs from fork repo?
If you could tell me it would be great. Thank you : )
Is there any way to write my own workflow for this?
You can use CI with the direct upload feature to get this done yourself.
but github secrets on not available on pull request
It is.
GitHub Security Lab
Keeping your GitHub Actions and workflows secure Part 1: Preventing...
In this article, we’ll discuss some common security malpractices for GitHub Actions and workflows, and how to best avoid them. Our examples are based on real-world GitHub workflow implementation vulnerabilities the GitHub Security Lab has reported to maintainers.
Thank you, but pull_request_target.yml works only with respect to base branch then how I am going to get build file with respect to PR from fork?
This look little promising...try working with this.
If you have implemented preview things. Can u please share here?
Thank you : )
I have not implemented it for myself. Just know it should work
You can absolutely have pull requests make preview branches and comment that back to your PR.
Here is how I did it in an existing repo (I've changed some naming up). A few things to note on this workflow
- It's built for monorepos where you have multiple webapps (like turborepo)
- When it runs on the main branch it will simply deploy all the pages projects
- When it runs on a pull request trigger it will create preview deployments and comment those back onto the PR
- The code is written in a way where you can easily add more webapps and add them to the preview comment
Had to send it as a file, the message was too long
Thank you Adi, can you please send me the repo you are using this?
Is the previews for PRs from Fork Repo ?
I really need to implement this in one of my repo.
Thank you : )
Basically cloudflare support PR previews for the maintainer, collaborator and PR from the same repo but different branches. But it does not support PR previews for fork.
Unfortunately it's a private repo, I can't share it
I haven't tried for forks, but the steps above work for PRs in the main repo. I shared it to give an example of how one might do preview comments.
For forks, you'll just have to work out how to grant access to secrets etc. Which I think are available if you approve workflows?
Previews are builtin provided by cloudflare but only for the source branches not for the fork .
Can you tell me which GitHub actions event should I use so that I can get access to secret in PR?