Deploy app in monorepo via Vercel CLI in Github Actions

Hey guys, I am looking to deploy an app within my monorepo to Vercel via cli in Github Actions. I have Vercel projects setup for each app in the monorepo. I am following this documentation but am having issues with pulling the correct environment variables. When I run vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }} it pulls env variables from $TEAM/$ROOT , but my environment variables are located at $TEAM/$PROJECT ( PROJECT correlating to the Vercel project name for that app).

I’ve also tried running a vercel link in the prior step and specifying the current working directory with --cwd when running but it says it can’t find a project at $TEAM/$PROJECT even though that project does exist in Vercel.

Has anybody else deployed an app inside of their monorepo to Vercel via Github Actions?

- name: Install Vercel CLI
  run: npm install --global vercel@latest
- name: Pull Vercel Environment Information
  run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}
- name: Build Project Artifacts
  run: vercel build --debug --token=${{ secrets.VERCEL_TOKEN }}
- name: Deploy Project Artifacts to Vercel
  run: vercel deploy --logs --token=${{ secrets.VERCEL_TOKEN }}

I’m seeing that the configuration I’m looking for may be similar to what @ezeikel was talking about here

What worked for our situation was to run vercel link prior to pulling environment information. In that vercel link we linked the project via the --project flag and the team via the --scope flag.

vercel link --yes --project ${{ secrets.PROJECT_ID }} --scope team-slug --token=${{ secrets.VERCEL_TOKEN }}

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.