I am trying do deploy a NX Monorepo Next.js project via Gitlab CI to Vercel.
Here is .yml
file.
image: node:lts
stages:
- build
- web-test
- deploy
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- node_modules/
build website:
stage: build
script:
- npm install
- npm i @nrwl/cli -g
- nx run shop-wine:build
artifacts:
paths:
- ./dist
test website:
stage: web-test
script:
- npm install
- npm i @nrwl/cli -g
- nx run shop-wine:serve &
- sleep 60
- curl "http://localhost:4200" | grep -q "Welcome shop-wine"
deploy-to-vercel:
stage: deploy
variables:
PREVIEW_URL: $CI_PROJECT_NAME-$CI_COMMIT_REF_SLUG.$VERCEL_USER.vercel.app
VERCEL_ORG_ID: $VERCEL_ORG_ID
VERCEL_PROJECT_ID: $VERCEL_PROJECT_ID
rules:
- if: $CI_COMMIT_TAG
- if: $CI_COMMIT_BRANCH == 'main'
environment:
name: vercel/$CI_COMMIT_REF_NAME
url: https://$PREVIEW_URL
script:
- npm i -g vercel
- DEPLOYMENT_URL=$(VERCEL_ORG_ID=$VERCEL_ORG_ID VERCEL_PROJECT_ID=$VERCEL_PROJECT_ID vercel --confirm -t $VERCEL_TOKEN --scope $VERCEL_USER)
- vercel alias set $DEPLOYMENT_URL $PREVIEW_URL -t $VERCEL_TOKEN --scope $VERCEL_USER
There are no problems with build
and web-test
stages but when I get to manual deploy-to-vercel
stage I am getting the following error from GitLab:
Here are the overrides on Vercel:
I am also using a plugin to automaticaly deploy to Vercel. As you can see it is deployed with success ahead of build
test
and manual deploy-to vercel
stages.
But when it gets to manual deploy-to-vercel
here is Vercel error. Let me know if I am doing something wrong.