feat: ci脚本

This commit is contained in:
rd
2025-08-08 12:10:07 +08:00
parent 559f3774b9
commit 983066d3c6
2 changed files with 97 additions and 1 deletions

96
.drone.yml Normal file
View File

@ -0,0 +1,96 @@
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

View File

@ -2,7 +2,7 @@
<div class="navbar-wrap">
<div class="left-wrap">
<a-space class="cursor-pointer" @click="router.push('/')">
<img src="@/assets/logo.svg" alt="" />
<img src="@/assets/LOGO.svg" alt="" />
</a-space>
</div>
<div class="flex-1">