Commit c4f0d6dd authored by ThinhNC's avatar ThinhNC

fix(ci): update gitlab ci to official vercel pipeline template

parent d12ffae6
Pipeline #53073 failed with stage
# 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
# Standard template matching official Vercel documentation:
# https://vercel.com/kb/guide/how-can-i-use-gitlab-pipelines-with-vercel
image: node:20-alpine
image: node:20
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)
# 1. Preview Deployment (Tất cả các nhánh tính năng trừ staging, main)
deploy_preview:
stage: deploy
rules:
- if: '$CI_COMMIT_BRANCH != "main" && $CI_COMMIT_BRANCH != "master"'
except:
- staging
- main
before_script:
- npm install --global pnpm vercel
script:
- vercel pull --yes --environment=preview --token=$VERCEL_TOKEN
- vercel build --token=$VERCEL_TOKEN
......@@ -36,11 +23,14 @@ deploy_preview:
VERCEL_ORG_ID: $VERCEL_ORG_ID
VERCEL_PROJECT_ID: $VERCEL_PROJECT_ID
# 2. Production Deployment (Triggered only when merging into main/master)
# 2. Production Deployment (Kích hoạt khi push lên nhánh staging, main)
deploy_production:
stage: deploy
rules:
- if: '$CI_COMMIT_BRANCH == "main" || $CI_COMMIT_BRANCH == "master"'
only:
- staging
- main
before_script:
- npm install --global pnpm vercel
script:
- vercel pull --yes --environment=production --token=$VERCEL_TOKEN
- vercel build --prod --token=$VERCEL_TOKEN
......
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