Next build error when ran in github action
Hello, I'm trying to create a CI workflow for my nextjs website. The problem is that I keep getting a build error from convex when running my build step. I don't have this error when I run
bun run build
locally though.
5 Replies
Thanks for posting in <#1088161997662724167>.
Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets.
- Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.)
- Use search.convex.dev to search Docs, Stack, and Discord all at once.
- Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI.
- Avoid tagging staff unless specifically instructed.
Thank you!
Do you want your github action to both deploy your convex functions to production + build and deploy your Next.js frontend? Or do you only want to do parts of this (like only build the frontend).
If you're trying to deploy both convex + frontend, you'll want a deploy command like
npx convex deploy --cmd 'npm run build'
(I'm not familiar enough with bun to know the exact equivalents -- see https://docs.convex.dev/production/hosting/custom#custom-hosting).
Usually build
on its own just builds the frontend, and needs to be wrapped in npx convex deploy
which handles setting the convex URL in an environment variable (NEXT_PUBLIC_CONVEX_URL
is the default for next apps) + deploying your convex functionsCustom Domains & Hosting | Convex Developer Hub
Serve requests from any domains and host your frontend on any static hosting provider, such as GitHub.
I was trying to just build my frontend to make sure it can complete successfully as a part of my CI. For actually deploying to vercel I haven't had issues using the below build command. I assumed that maybe this issue was that the convex url was missing, but even when pulling my env vars from vercel before the build step in my CI it still throws the error above.
cd ../../packages/backend && npx convex deploy --cmd 'cd ../../apps/web && turbo run build' --cmd-url-env-var-name NEXT_PUBLIC_CONVEX_URL
what about setting
NEXT_PUBLIC_CONVEX_URL
explicitly in CI (just to rule out something fishy with pulling in env vars from elsewhere)
I'm also kind of surprised that a build step would be hitting this error, since that looks like a runtime error. What does your build command look like? (Mine is just next build
)root package.json
"build": "turbo build --parallel"
next app package.json
"build": "next build"
turbo.json
Here's my action as well
this is without the testing I did with pulling env vars from vercel before building