Files
lunar-mini/.gitea/workflows/server-deploy.yml
T
gouki b5bdf4c88d
Publish Mini Program Dev Version / publish (push) Failing after 10m47s
Build and Deploy Server / build (push) Failing after 2s
fix(wish-tree): 修复切换树时导航栏消失问题
- Canvas添加z-index: 1,确保不覆盖导航栏
- top-bar添加pointer-events: none,子元素恢复auto
- WXML添加trees.length保护,防止空数组访问
- switchTree添加空数组保护
2026-08-07 21:56:38 +00:00

101 lines
3.1 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.
name: Build and Deploy Server
on:
push:
branches:
- main
paths:
- "server/**"
- ".gitea/workflows/server-deploy.yml"
jobs:
build:
# 专属运行器:docker://golang:1.22-bookworm(注册于 doc79
runs-on: lunar-ci
steps:
- uses: https://gitea.neatcn.com/gouki/action-checkout@v4
with:
fetch-depth: 20
- name: Verify Go runtime
run: go version
- name: Install dependencies
working-directory: server
run: go mod download
- name: Run tests
working-directory: server
run: go test ./...
- name: Build application
working-directory: server
run: |
mkdir -p bin
go build -o bin/server cmd/main.go
- name: Build frontend (if exists)
working-directory: server
run: |
if [ -d "web" ]; then
echo "Building frontend..."
cd web
if [ -f "package.json" ]; then
npm ci
npm run build
fi
else
echo "No frontend directory found, skipping frontend build"
fi
- name: Create deployment package
working-directory: server
run: |
mkdir -p deploy
cp -r bin/ deploy/
cp -r migrations/ deploy/
cp -r scripts/ deploy/
if [ -d "web/dist" ]; then
cp -r web/dist/ deploy/public/
fi
tar -czf deploy.tar.gz deploy/
- name: Persist deployment package on runner host
run: |
test -f server/deploy.tar.gz
test -d /ci-artifacts
cp server/deploy.tar.gz "/ci-artifacts/server-deploy-${{ gitea.sha }}.tar.gz"
cp server/deploy.tar.gz /ci-artifacts/server-deploy-latest.tar.gz
ls -la /ci-artifacts/server-deploy-latest.tar.gz
echo "Deployment package saved on runner host: /opt/lunar/ci-artifacts/server-deploy-latest.tar.gz"
- name: Send success notification
if: success()
env:
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
run: |
chmod +x .gitea/scripts/notify.sh
.gitea/scripts/notify.sh success \
"后端服务部署成功" \
"部署包已保存到: /opt/lunar/ci-artifacts/server-deploy-latest.tar.gz"
- name: Send failure notification
if: failure()
env:
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
run: |
chmod +x .gitea/scripts/notify.sh
.gitea/scripts/notify.sh failure \
"后端服务部署失败" \
"请检查 Actions 日志了解失败原因"
- name: Cleanup
if: always()
run: |
rm -rf server/deploy/
rm -f server/deploy.tar.gz