feat: 添加目录触发的 Actions 工作流
Publish Mini Program Dev Version / publish (push) Waiting to run
Build and Deploy Server / build (push) Waiting to run

- miniapp-preview.yml: 只在 mini/** 目录变更时触发
- server-deploy.yml: 只在 server/** 目录变更时触发
- 使用 hk 运行器
- 避免不必要的资源浪费
This commit is contained in:
gouki
2026-08-06 22:42:58 +00:00
parent f801094aad
commit 09d8a39946
2 changed files with 82 additions and 1 deletions
+4 -1
View File
@@ -4,10 +4,13 @@ on:
push:
branches:
- main
paths:
- "mini/**"
- ".gitea/workflows/miniapp-preview.yml"
jobs:
publish:
runs-on: ubuntu-latest
runs-on: hk
steps:
- uses: https://gitea.neatcn.com/gouki/action-checkout@v4
with:
+78
View File
@@ -0,0 +1,78 @@
name: Build and Deploy Server
on:
push:
branches:
- main
paths:
- "server/**"
- ".gitea/workflows/server-deploy.yml"
jobs:
build:
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: Upload deployment artifact
uses: https://gitea.neatcn.com/gouki/action-upload-artifact@v3
with:
name: server-deploy
path: server/deploy.tar.gz
retention-days: 7
- name: Cleanup
if: always()
run: |
rm -rf server/deploy/
rm -f server/deploy.tar.gz