fix: CI/CD build errors
Build and Deploy / build (push) Failing after 3s
Build and Deploy / deploy (push) Has been skipped

- Simplified go.mod with all dependencies
- Fixed generateRandomSecret function
- Updated Dockerfile to use debian bookworm
- Simplified CI workflow to single job
- Fixed Gitea Actions syntax (github.ref)
This commit is contained in:
2026-07-16 09:23:24 +00:00
parent 029e5ac0d0
commit 731e00855b
4 changed files with 90 additions and 83 deletions
+12 -14
View File
@@ -1,9 +1,10 @@
package main
import (
"crypto/rand"
"encoding/hex"
"fmt"
"log"
"os"
"anticaptcha/internal/captcha"
"anticaptcha/internal/config"
@@ -54,18 +55,19 @@ func main() {
// 静态文件服务(前端)
r.Static("/assets", "./web/dist/assets")
r.StaticFile("/", "./web/dist/index.html")
r.StaticFile("/favicon.ico", "./web/dist/favicon.ico")
r.NoRoute(func(c *gin.Context) {
c.File("./web/dist/index.html")
})
// API 路由
captchaHandler := handler.NewCaptchaHandler(captcha.NewHandler("./models"))
captchaHandler.RegisterRoutes(r.Group(""), true)
// 安装路由
r.GET("/install", func(c *gin.Context) {
c.File("./web/dist/index.html")
})
r.POST("/api/install", handleInstall)
r.GET("/api/install/check", func(c *gin.Context) {
c.JSON(200, gin.H{"installed": config.IsInstalled()})
})
// 健康检查
r.GET("/health", func(c *gin.Context) {
@@ -77,7 +79,7 @@ func main() {
if config.Cfg != nil {
addr = fmt.Sprintf("%s:%d", config.Cfg.Server.Host, config.Cfg.Server.Port)
}
fmt.Printf(`
╔════════════════════════════════════════════════════════════════╗
║ AntiCaptcha Server v1.0.0 ║
@@ -169,15 +171,11 @@ func handleInstall(c *gin.Context) {
c.JSON(200, gin.H{
"message": "安装成功",
"config": cfg,
})
}
func generateRandomSecret() string {
const charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
b := make([]byte, 64)
for i := range b {
b[i] = charset[os.New(0).UnixNano()%int64(len(charset))]
}
return string(b)
b := make([]byte, 32)
rand.Read(b)
return hex.EncodeToString(b)
}