I’m trying to deploy a Gatsby based website via github integration. The build fails because Gatsby requires Node 18, while the highest version available in Cloudflare is 17 when you change the NODE_VERSION environment variable. I searched online and some suggestions include using
yarn install --ignore-engines
How can I do this in the deployment?
The other question stems from what I did next, I just built the site then used direct upload. To do this I had to create another project to change the deployment type, then delete my custom domain to reassign it.
Is there anyway I can change the deployment type without having downtime for my domain?
You can’t do Node 18 (and therefore the latest Gatsby) on the current Pages build image. This will change when the new image arrives, soon™. Until then, direct upload is the way to go. You can use Github Actions to automate this so it will still deploy automatically when you push to the main branch.
You can’t change the deployment type on an existing project, unfortunately.
Sadly, you can’t atomically “move” a domain from one Pages project to another (I just tried it to see if this has changed, and it has not). The fastest way, then, would be to have the new project up and ready, then delete the domain from the old one and immediately add it to the new one. Downtime in that case should™ be less than a minute.
This is the Github Action I use to deploy a site to Pages.
name: Deploy to Cloudflare Pages
run-name: ${{ github.actor }} created a deployment.
on:
push:
branches:
- main
- dev
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
deployments: write
steps:
- uses: actions/[email protected]
- name: Install dependencies
run: npm ci
- name: Build site
run: npm run build
- name: Publish to Cloudflare Pages
uses: cloudflare/[email protected]
with:
apiToken: ${{ secrets.CF_API_TOKEN }}
gitHubToken: ${{ secrets.GH_TOKEN }}
accountId: 'c4181c74ba33fc8edf2d8cca0dc37bd1'
projectName: 'igloo'
directory: './public'
You probably need to manually deploy it the first time with wrangler to create the project. (I say “probably” because I’m not sure if this has changed.)