Deploying a multihost configuration with Cloudflare Pages

Has anyone experience deploying a multihost configuration with Cloudflare Pages (CFP)? I’m currently using Netlify, which supports monorepos, so I can connect the same repo to different sites and just change the publish directory accordingly (so that every time I push a commit all sites are built and deployed).

CFP doesn’t support monorepos yet, so I’ve been told to use GitHub Actions (GHA) and wrangler to directly upload my sites, but I have zero experience with them (GHA), hence my search for help here.

I will perfectly understand if this is not the right forum to ask this.

Thanks in advance,
Rodrigo

1 Like

Cloudflare provides their GitHub actions for pages.

Simply create a workflow for each site in your repo.

1 Like

I see. Thank you, @razon. I was struggling as I thought I had to specify the deployment of the different sites under the same workflow file. Now it’s much clearer to me. I guess that if I set some environment variables they’ll be specific to that deployment, right?

I think you can create either multiple workflows or multiple jobs inside one workflow, and then specify the projectName for each site.

jobs:
  publish-site-1:
  publish-site-2:
  publish-site-3:

The best option is using matrix strategy, you can reuse the same job with different inputs (such as projectName), but it’s a little bit complex.

jobs:
  publish:
    strategy:
      matrix:
        sites: [proj1, proj2]
    steps:
      ...
1 Like

Leaving this here for future reference. My GHA is now here and properly working and deploying three sites in CFP simultaneously.

Thank you very much for your help, @razon. I also want to thank @bwintx for guiding me through the process of setting up the GHA on the unofficial Hugo Discord server.

2 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.