2
0
mirror of https://github.com/acepanel/panel.git synced 2026-02-04 11:27:17 +08:00

workflow: 合并前后端工作流

This commit is contained in:
耗子
2024-12-20 15:51:48 +08:00
parent c5b23aaa57
commit bbe07f7bdd
4 changed files with 48 additions and 55 deletions

View File

@@ -1,11 +1,46 @@
name: Backend
name: Build
on:
push:
branches:
- main
pull_request:
jobs:
build:
frontend:
runs-on: ubuntu-24.04
defaults:
run:
working-directory: web
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: latest
run_install: true
package_json_file: web/package.json
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: 'pnpm'
cache-dependency-path: web/pnpm-lock.yaml
- name: Build frontend
# We need to run the dev server first to generate the auto-imports files
run: |
cp .env.production .env
cp settings/proxy-config.example.ts settings/proxy-config.ts
pnpm dev &
sleep 5
kill %1
pnpm build
- name: Upload frontend
uses: actions/upload-artifact@v4
with:
name: frontend
path: web/dist/ # https://github.com/actions/upload-artifact/issues/541
backend:
needs: frontend
runs-on: ubuntu-24.04
strategy:
matrix:
@@ -23,19 +58,11 @@ jobs:
go-version: 'stable'
- name: Install dependencies
run: go mod tidy
- name: Wait for frontend build
uses: lewagon/wait-on-check-action@v1.3.4
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
check-name: 'build (frontend)'
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Download frontend
uses: dawidd6/action-download-artifact@v7
uses: actions/download-artifact@v4
with:
workflow: frontend.yml
name: frontend
path: internal/embed/frontend
check_artifacts: true
- name: Set build info
run: |
echo "VERSION=$(git describe --tags --abbrev=0 2>/dev/null || echo '0.0.0')" >> $GITHUB_ENV

View File

@@ -1,42 +0,0 @@
name: Frontend
on:
push:
branches:
- main
pull_request:
jobs:
build:
name: build (frontend)
runs-on: ubuntu-24.04
defaults:
run:
working-directory: web
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: latest
run_install: true
package_json_file: web/package.json
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: 'pnpm'
cache-dependency-path: web/pnpm-lock.yaml
- name: Build frontend
# We need to run the dev server first to generate the auto-imports files
run: |
cp .env.production .env
cp settings/proxy-config.example.ts settings/proxy-config.ts
pnpm dev &
sleep 5
kill %1
pnpm build
- name: Upload frontend
uses: actions/upload-artifact@v4
with:
name: frontend
path: web/dist/ # https://github.com/actions/upload-artifact/issues/541

View File

@@ -141,6 +141,6 @@ func initWeb() (*app.Web, error) {
return nil, err
}
validation := bootstrap.NewValidator(db)
web := app.NewWeb(koanf, mux, server, gormigrate, cron, validation)
web := app.NewWeb(koanf, mux, server, gormigrate, cron, queue, validation)
return web, nil
}

View File

@@ -1,6 +1,7 @@
package app
import (
"context"
"errors"
"fmt"
"net/http"
@@ -12,6 +13,8 @@ import (
"github.com/gookit/validate"
"github.com/knadh/koanf/v2"
"github.com/robfig/cron/v3"
"github.com/TheTNB/panel/pkg/queue"
)
type Web struct {
@@ -20,15 +23,17 @@ type Web struct {
server *hlfhr.Server
migrator *gormigrate.Gormigrate
cron *cron.Cron
queue *queue.Queue
}
func NewWeb(conf *koanf.Koanf, router *chi.Mux, server *hlfhr.Server, migrator *gormigrate.Gormigrate, cron *cron.Cron, _ *validate.Validation) *Web {
func NewWeb(conf *koanf.Koanf, router *chi.Mux, server *hlfhr.Server, migrator *gormigrate.Gormigrate, cron *cron.Cron, queue *queue.Queue, _ *validate.Validation) *Web {
return &Web{
conf: conf,
router: router,
server: server,
migrator: migrator,
cron: cron,
queue: queue,
}
}
@@ -43,6 +48,9 @@ func (r *Web) Run() error {
r.cron.Start()
fmt.Println("[CRON] cron scheduler started")
// start queue
r.queue.Run(context.TODO())
// run http server
if r.conf.Bool("http.tls") {
cert := filepath.Join(Root, "panel/storage/cert.pem")