Files
lunar-mini/.gitea/workflows/server-deploy.yml
T
gouki c19854ce77
Publish Mini Program Dev Version / publish (push) Waiting to run
Build and Deploy Server / build (push) Waiting to run
fix: 参考 new-pet 项目修正 Actions 配置
- 使用 hk 运行器(空闲状态)
- 添加详细注释说明
- 参考 new-pet 的成熟配置
- 确保只在指定目录变更时触发
2026-08-06 22:59:56 +00:00

82 lines
2.2 KiB
YAML

name: Build and Deploy Server
on:
push:
branches:
- main
paths:
- "server/**"
- ".gitea/workflows/server-deploy.yml"
jobs:
build:
# 使用 hk 运行器(空闲状态)
runs-on: hk
steps:
- uses: https://gitea.neatcn.com/gouki/action-checkout@v4
with:
fetch-depth: 20
- name: Setup Go
uses: https://gitea.neatcn.com/gouki/action-setup-go@v4
with:
go-version: '1.22'
- 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: /ci-artifacts/server-deploy-latest.tar.gz"
- name: Cleanup
if: always()
run: |
rm -rf server/deploy/
rm -f server/deploy.tar.gz