Files
lingji-work-fe/.drone.yml
lidognbin c45254ed1b build:升级 pnpm版本以支持 Windows 平台
- 将 pnpm 版本从 9.12.3 升级到 10.13.1
-此升级是为了增加对 Windows 操作系统的支持
2025-08-14 18:32:53 +08:00

98 lines
3.1 KiB
YAML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

kind: pipeline
type: docker
name: build-deploy
clone:
depth: 1
trigger:
event: [ push, custom ]
branch: [ master, test, feature/ldb_build ]
steps:
- name: install & build
image: node:22-bullseye-slim
environment:
# 统一走镜像,避免 npmjs 超时
NPM_CONFIG_REGISTRY: https://registry.npmmirror.com
PNPM_REGISTRY: https://registry.npmmirror.com
# 提高容错
PNPM_FETCH_RETRIES: "5"
PNPM_FETCH_RETRY_MINTIMEOUT: "2000"
PNPM_FETCH_RETRY_MAXTIMEOUT: "60000"
PNPM_FETCH_TIMEOUT: "600000"
CI: "true"
# 固定 pnpm store 到缓存卷
PNPM_STORE_DIR: /cache/pnpm
volumes:
- name: build-output
path: /runner/builds
- name: pnpm-store-cache
path: /cache
commands:
- node -v && npm -v
- corepack enable
- corepack prepare pnpm@10.13.1 --activate
# 关键:先把所有包拉进本地 store不执行 postinstall
- pnpm fetch
# 离线优先安装:命中 store 就不走网络;锁住 lockfile
- pnpm install --frozen-lockfile --prefer-offline
- mkdir -p /runner/builds/${DRONE_REPO_NAME}/${DRONE_BRANCH}
- |
case "${DRONE_BRANCH}" in
feature/ldb_build|test) pnpm run build:test ;;
master) pnpm run build:prod ;;
*) echo "❌ 未配置此分支的构建规则: ${DRONE_BRANCH}"; exit 1 ;;
esac
- rm -rf /runner/builds/${DRONE_REPO_NAME}/${DRONE_BRANCH}/*
- cp -r dist/* /runner/builds/${DRONE_REPO_NAME}/${DRONE_BRANCH}/
- name: deploy to spug
image: curlimages/curl
when:
status: [ success ]
branch: [ feature/ldb_build, test, master ]
environment:
SPUG_DEPLOY_URL:
from_secret: spug_deploy_lingji_work_fe_url
SPUG_DEPLOY_TOKEN:
from_secret: spug_deploy_token
commands:
- |
echo "🚀 部署到 Spug: 分支 ${DRONE_BRANCH}"
curl -X POST "$SPUG_DEPLOY_URL?name=${DRONE_BRANCH}&token=$SPUG_DEPLOY_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"ref": "refs/heads/'"${DRONE_BRANCH}"'",
"before": "'"${DRONE_COMMIT_BEFORE}"'",
"after": "'"${DRONE_COMMIT_SHA}"'",
"commits": [{"message": "发布'"${DRONE_BRANCH}${DRONE_COMMIT_SHA}"'"}]
}'
- name: notify feishu on failure
image: curlimages/curl
when:
status: [ failure ]
environment:
FEISHU_WEBHOOK:
from_secret: feishu_webhook_url
commands:
- |
curl -X POST "$FEISHU_WEBHOOK" \
-H "Content-Type: application/json" \
-d '{
"msg_type": "text",
"content": { "text": "❌ Drone-CI 执行失败 ❗️\n项目: '${DRONE_REPO_NAME}'\n分支: '${DRONE_BRANCH}'\n提交: '${DRONE_COMMIT_SHA:0:8}'" }
}'
volumes:
- name: build-output
host:
path: /www/dk_project/dk_compose/spug/data/repos/build/drone-runner/builds
- name: pnpm-store-cache
host:
# 建议为 pnpm store 单独准备一个可持久化目录
path: /www/dk_project/dk_compose/spug/cache/pnpm-store