Files
lingji-work-fe/.drone.yml
2025-08-08 12:10:07 +08:00

96 lines
2.4 KiB
YAML
Raw 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 # ✅ 只拉取最近一次 commit显著加快 clone 速度
trigger:
event:
- push
- custom
branch:
- master
- test
- feature/ldb_build
steps:
- name: install & build
image: node:23.9.0
volumes:
- name: build-output
path: /runner/builds
commands:
- corepack enable
- corepack prepare pnpm@8.15.5 --activate
- pnpm install
- 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