Publish on Cloudflare Pages with unsupported language versions
Emmanuel Gautier / December 06, 2022
2 min read
It may happen that a version of Node is not supported yet by Cloudflare and will remain not supported for some weeks. That can happen even if it is a Long Term Support (LTS) version. As I write those lines, the latest NodeJS LTS version is not supported yet (lts/hydrogen 18.x). This situation can be painful when a framework drops older version support or if you can not wait for having new features from a newer version of the language. For example, the newer major version of Gatsby, Gatsby 5, dropped support for older Node versions including the older LTS versions. CLoudflare teams make some proposals about the next upgrades and the upgrade cycle on Github Page Build discussion page.
At this moment, you have no way to make Cloudflare runtime build your project with the newer version of Gatsby. Of course, if you can, it is better to wait that Cloudflare upgrades its runtime and support the more recent version of Node. But if you want to upgrade and get benefits from the newer version of Node without removing Cloudflare Pages deployment and without waiting for Cloudflare upgrade, you have a solution we will talk about in this article.
Cloudflare Pages offer a way to build static sites and serve them thanks to their CDN. But you can choose to use only the hosting and serving part, and build the static site or static app by yourself. We already described this solution when we described how to have a Monorepo with Cloudflare Pages. This solution is to build the project on GitHub Actions (or any other CI solution) and push the build to Cloudflare.
Here is an example:
name: Publish
on:
push:
branches:
- main
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
deployments: write
steps:
- name: Checkout 🛎
uses: actions/checkout@v3
- name: Setup node env 🏗
uses: actions/setup-node@v3
with:
node-version: lts/gallium
cache: 'yarn'
- name: Install dependencies 👨🏻💻
run: yarn --frozen-lockfile --silent
- name: Run build
run: yarn build
- name: Publish
uses: cloudflare/pages-action@1
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: gatsby-website
directory: ./public
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
Consulting
If you're seeking solutions to a problem or need expert advice, I'm here to help! Don't hesitate to book a call with me for a consulting session. Let's discuss your situation and find the best solution together.
Related Posts
Collapsible sections in Markdown
Collapsible sections can help keep markdown organized and user-friendly. In this quick guide, we'll show how to create collapsible sections in a markdown.
Read Package.json file from Node.JS module
When you write a program you may want to read the content of the package.json file like what is the current package version. Here is one very simple way to read the content of this file.
Import a JSON file content from a Node.JS module
With the new Node.JS module it is possible to read the content of a JSON file with the import function but there is the right way to do it.
Featured Posts
Introducing new blog about OAuth, OpenID Connect, and IAM Solutions
I'm excited to announce the launch of a new blog named CerberAuth, where I'll be exploring the world of OAuth, OpenID Connect, and IAM solutions for modern security.
How to deal with Docker Hub rate limit on AWS
Since 2020, DockerHub has been limited to only 200 container image pull requests per six hours. This article will help you to deal with this limitation on AWS.
How to enable Python type checking in VSCode
Python now has support for type hints. In this article, we will see how to enable better IntelliSense and type checking analysis in VSCode.