GitHub Actions to Cloudflare Workers Sites

Lucian Daniliuc
Monitive — Once Upon A Site
2 min readOct 8, 2020

As time goes by, I’m looking for solutions that require as little maintenance as possible. One of those is deploying our client web app and our homepage directly on the CDN edge, with GitHub Actions.

Not only we don’t need a server to host the app, but the deployment script is also serverless and maintenance-less. This allows me to focus on important tasks, knowing that deployment and serving of the app is always blazing fast.

Cloudflare Workers Sites allows us to serve the app from Cloudflare’s network of CDN servers without any actual origin. The site is out there, in the cloud, being served faster than any regular website would be. It literally takes milliseconds for the site to load in your browser, wherever you are in the world. And that goes a long way for user experience.

GitHub Actions enables us to build simple (or complicated) deployment flows, building the app and deploying it to the corresponding location.

As of the writing of this article, I don’t think there’s a faster delivery system than hosting your website directly on the CDN edge.

I won’t go into the details of how Cloudflare Workers Sites works, since there’s a lot of documentation for that, however here’s our wrangler.toml file, used by Cloudflare to deploy the website into “the cloud”:

This is pretty much it. Publishing the app from the local command line is just a matter of running:

$ wrangler publish --env staging

Now, for the automation part, here comes GitHub Actions. Our development flow involves pushing to staging any merge into the master branch, and pushing to production any new release published. For this to work, we have two workflow files, release.yml and staging.yml, the main differences between these is when it’s run and deployment keys.

As for the releases, we want those deployed only when a release is published, so the workflow file begins with:

And that’s pretty much it. Now, whenever code is pushed to master, a PR to master is created or a new Release is published, GitHub actions builds the app and deploys it to the corresponding environment.

Our web app GitHub Actions

I hope you found this article useful.

If you’re looking for a simple solution to detect downtime before your customers do, check out Monitive.com (also deployed by GitHub Actions & Cloudflare Workers Sites).

--

--

Lucian Daniliuc
Monitive — Once Upon A Site

Entrepreneur @ Monitive.com, Team Leader, Scrum Master, Zend Certified Engineer, passionate photographer enthusiastic about success.