Skip to content

Commit

Permalink
ci: 打包前端
Browse files Browse the repository at this point in the history
  • Loading branch information
RockChinQ committed Apr 14, 2024
1 parent 1cd5e93 commit 94cc9e3
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/build-latest-backend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,21 @@ jobs:
uses: actions/setup-go@v2
with:
go-version: 1.22.1

- name: Set up Node.js 20.12
uses: actions/setup-node@v2
with:
node-version: 20.12

- name: Build the backend
run: |
go build -o bin/campux main.go
- name: Build the frontend
run: |
cd frontend
npm install
npm run build
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ FROM golang:1.22.1
WORKDIR /app

COPY bin/campux /app/campux
COPY frontend/dist /app/frontend/dist

EXPOSE 8080

Expand Down
10 changes: 10 additions & 0 deletions backend/controller/api.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package controller

import (
"net/http"
"strings"
"time"

"github.com/RockChinQ/Campux/backend/service"
Expand Down Expand Up @@ -37,6 +39,14 @@ func NewApiController(
)
}

r.Use(func(c *gin.Context) {
if strings.HasPrefix(c.Request.URL.Path, "/v1") {
c.Next()
return
}
http.ServeFile(c.Writer, c.Request, "./frontend/dist"+c.Request.URL.Path)
})

rg := r.Group("/v1")

// bind routes
Expand Down
1 change: 1 addition & 0 deletions backend/database/po.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
type UserGroup string

const (
USER_GROUP_ANY UserGroup = "any"
USER_GROUP_ADMIN UserGroup = "admin"
USER_GROUP_MEMBER UserGroup = "member"
USER_GROUP_USER UserGroup = "user"
Expand Down

0 comments on commit 94cc9e3

Please sign in to comment.