Next.js Discord

Discord Forum

Turborepo deployment on Vercel via GitHub actions

Unanswered
English Spot posted this in #help-forum
Open in Discord
English SpotOP
Hello,

I'm trying to deploy our monorepo with Turborepo on Vercel via GitHub actions but I'm slightly confused on the Root Directory option in Vercel Settings and Vercel CLI. I've read through the docs, as well as looked into deployment from the new Production Monorepos with Turborepo academy course.

Here's my setup:

I have updated my project settings to the following:

Build command: cd ../.. && turbo build --filter=web
Root Directory: apps/web


In my root workspace, I have the following scripts:

    "vercel:link": "vercel link --token=$VERCEL_TOKEN --yes --repo",
    "vercel:envs": "turbo run vercel:envs",
    "vercel:build": "turbo run vercel:build",
    "vercel:deploy": "turbo run vercel:deploy"


Then, inside my web app (apps/web), I have the following scripts:

    "vercel:envs": "vercel pull --yes --environment=preview --token=$VERCEL_TOKEN --git-branch=$GIT_BRANCH",
    "vercel:build": "vercel build --token=$VERCEL_TOKEN",
    "vercel:deploy": "vercel deploy --prebuilt --token=$VERCEL_TOKEN"


Now, the build works fine and is created. When it comes to deployment via vercel deploy, I've sort of hit a wall. From the setup, I had the following error in the deploy step:

> web@0.1.0 vercel:deploy /home/runner/work/X/apps/web
> vercel deploy --prebuilt --token=$VERCEL_TOKEN

Vercel CLI 50.12.3
Retrieving project…
Error: The provided path “~/x/x/apps/web/apps/web” does not exist. To change your Project Settings, go to https://vercel.com/x/x/settings
 ELIFECYCLE  Command failed with exit code 1.

Note: I've redacted the path with x/x, it isn't actually like this.

I looked into where the build was created: Build Completed in apps/web/.vercel/output [2m] . From this, I thought the deploy command is running two directories deep, so I updated the script to this:

    "vercel:deploy": "cd ../.. && vercel deploy --prebuilt --token=$VERCEL_TOKEN"


continued below..

2 Replies

English SpotOP
This resulted in the following error:

web:vercel:deploy
cache bypass, force executing c6d462b0e188bda8
> web@0.1.0 vercel:deploy /home/runner/work/X/apps/web
> cd ../.. && vercel deploy --prebuilt --token=$VERCEL_TOKEN
Vercel CLI 50.12.3
Retrieving project…
Error: The "--prebuilt" option was used, but no prebuilt output found in ".vercel/output". Run `vercel build` to generate a local build.
 ELIFECYCLE  Command failed with exit code 1.


Clearly, this didn't work either. As a final resort, I moved the vercel deploy script to the root workspace, and that resulted in an error as well:

Vercel CLI 50.12.3
Retrieving project…
Error: The "--prebuilt" option was used, but no prebuilt output found in ".vercel/output". Run `vercel build` to generate a local build.
 ELIFECYCLE  Command failed with exit code 1.


Sorry for the long message, but I've sort of hit a wall. Any help here would be appreciated. 🙏
English SpotOP
Here's the workflow for reference:

jobs:
  Deploy-Preview:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: pnpm/action-setup@v4
      - name: Set up Node.js
        uses: actions/setup-node@v4
        with:
          node-version: '22.18.0'
          cache: 'pnpm'
      - name: Install dependencies
        run: pnpm install
      - name: Link Vercel Project
        run: pnpm vercel:link
      - name: Pull Vercel Environment Information
        run: pnpm vercel:envs
      - name: Build Project Artifacts
        run: pnpm vercel:build
      - name: Deploy Project Artifacts to Vercel
        run: pnpm vercel:deploy 2>&1 | tee deploy-output.txt