Commit d12ffae6 authored by ThinhNC's avatar ThinhNC

ci: add GitLab CI/CD pipeline configuration for Vercel and update gitignore for build artifacts

parent 751a54e2
Pipeline #53070 failed
...@@ -34,9 +34,13 @@ yarn-error.log* ...@@ -34,9 +34,13 @@ yarn-error.log*
.env* .env*
!.env.example !.env.example
# vercel # vercel & build cache
.vercel .vercel
.pnpm-store
# typescript # typescript
*.tsbuildinfo *.tsbuildinfo
next-env.d.ts next-env.d.ts
.vercel
.env*
# GitLab CI/CD Pipeline for deploying Next.js to Vercel using Vercel CLI
# Reference: https://vercel.com/kb/guide/how-can-i-use-gitlab-pipelines-with-vercel
image: node:20-alpine
stages:
- deploy
variables:
PNPM_HOME: "/root/.local/share/pnpm"
PATH: "$PNPM_HOME:$PATH"
before_script:
- npm install -g pnpm vercel
- pnpm config set store-dir .pnpm-store
# Cache pnpm dependencies and Next.js build cache to speed up pipelines
cache:
key:
files:
- pnpm-lock.yaml
paths:
- .pnpm-store
- .next/cache
# 1. Preview Deployment (Triggered on feature branches and Merge Requests)
deploy_preview:
stage: deploy
rules:
- if: '$CI_COMMIT_BRANCH != "main" && $CI_COMMIT_BRANCH != "master"'
script:
- vercel pull --yes --environment=preview --token=$VERCEL_TOKEN
- vercel build --token=$VERCEL_TOKEN
- vercel deploy --prebuilt --token=$VERCEL_TOKEN
variables:
VERCEL_ORG_ID: $VERCEL_ORG_ID
VERCEL_PROJECT_ID: $VERCEL_PROJECT_ID
# 2. Production Deployment (Triggered only when merging into main/master)
deploy_production:
stage: deploy
rules:
- if: '$CI_COMMIT_BRANCH == "main" || $CI_COMMIT_BRANCH == "master"'
script:
- vercel pull --yes --environment=production --token=$VERCEL_TOKEN
- vercel build --prod --token=$VERCEL_TOKEN
- vercel deploy --prebuilt --prod --token=$VERCEL_TOKEN
variables:
VERCEL_ORG_ID: $VERCEL_ORG_ID
VERCEL_PROJECT_ID: $VERCEL_PROJECT_ID
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment