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/[email protected]
- name: Setup node env 🏗
uses: actions/setup-[email protected]
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-[email protected]
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: gatsby-website
directory: ./public
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
Related Posts
Keep the same Node.js version between local environment and Github Actions
It can be complicated to have the same Node version between the local environment and the CI/CD. The latest Node.js version or the latest lts is released recently and if you want to upgrade to the Node version, usually you can forget to configure one environment.
Keep the same Node.js version between local environment and Github Actions
It can be complicated to have the same Node version between the local environment and the CI/CD. The latest Node.js version or the latest lts is released recently and if you want to upgrade to the Node version, usually you can forget to configure one environment.
Publish multiple projects on a Monorepo on Cloudflare Pages
All the tooling provided by service providers is great and makes the developer's life much easier. Usually, those providers connect one git repository to an application. It works fine but it is not so easy when you work on a monorepo or if you want to make multiple deployments for more than one locale from only one source code.
Featured Posts
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.
How to manage Internationalization with NextJS SSG
Staticaly generating a website with the NextJS framework in different languages is not so obvious.