mirror of
https://github.com/go-gitea/gitea.git
synced 2025-07-25 23:06:11 +02:00
Add default bot url
This commit is contained in:
parent
1a55d39adc
commit
fc2c70033a
@ -2478,3 +2478,18 @@ ROUTER = console
|
|||||||
;PROXY_URL =
|
;PROXY_URL =
|
||||||
;; Comma separated list of host names requiring proxy. Glob patterns (*) are accepted; use ** to match all hosts.
|
;; Comma separated list of host names requiring proxy. Glob patterns (*) are accepted; use ** to match all hosts.
|
||||||
;PROXY_HOSTS =
|
;PROXY_HOSTS =
|
||||||
|
|
||||||
|
; [bots]
|
||||||
|
;; Enable/Disable bots capabilities
|
||||||
|
;ENABLED = false
|
||||||
|
;DEFAULT_BOTS_URL = https://gitea.com
|
||||||
|
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
;; settings for packages, will override storage setting
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
;[storage.bots_log]
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
;; storage type
|
||||||
|
;STORAGE_TYPE = local
|
||||||
|
@ -8,21 +8,23 @@ import (
|
|||||||
"code.gitea.io/gitea/modules/log"
|
"code.gitea.io/gitea/modules/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Builds settings
|
// Bots settings
|
||||||
var (
|
var (
|
||||||
Builds = struct {
|
Bots = struct {
|
||||||
Storage
|
Storage
|
||||||
Enabled bool
|
Enabled bool
|
||||||
|
DefaultBotsURL string
|
||||||
}{
|
}{
|
||||||
Enabled: true,
|
Enabled: false,
|
||||||
|
DefaultBotsURL: "https://gitea.com",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
func newBuilds() {
|
func newBuilds() {
|
||||||
sec := Cfg.Section("builds")
|
sec := Cfg.Section("bots")
|
||||||
if err := sec.MapTo(&Builds); err != nil {
|
if err := sec.MapTo(&Bots); err != nil {
|
||||||
log.Fatal("Failed to map Builds settings: %v", err)
|
log.Fatal("Failed to map Builds settings: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
Builds.Storage = getStorage("builds", "", nil)
|
Bots.Storage = getStorage("bots_log", "", nil)
|
||||||
}
|
}
|
@ -140,7 +140,7 @@ func Init() error {
|
|||||||
initLFS,
|
initLFS,
|
||||||
initRepoArchives,
|
initRepoArchives,
|
||||||
initPackages,
|
initPackages,
|
||||||
initBuilds,
|
initBots,
|
||||||
} {
|
} {
|
||||||
if err := f(); err != nil {
|
if err := f(); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -198,8 +198,8 @@ func initPackages() (err error) {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func initBuilds() (err error) {
|
func initBots() (err error) {
|
||||||
log.Info("Initialising Builds storage with type: %s", setting.Builds.Storage.Type)
|
log.Info("Initialising Bots storage with type: %s", setting.Bots.Storage.Type)
|
||||||
Builds, err = NewStorage(setting.Builds.Storage.Type, &setting.Builds.Storage)
|
Builds, err = NewStorage(setting.Bots.Storage.Type, &setting.Bots.Storage)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ import (
|
|||||||
"code.gitea.io/gitea/modules/bots"
|
"code.gitea.io/gitea/modules/bots"
|
||||||
"code.gitea.io/gitea/modules/json"
|
"code.gitea.io/gitea/modules/json"
|
||||||
"code.gitea.io/gitea/modules/log"
|
"code.gitea.io/gitea/modules/log"
|
||||||
|
"code.gitea.io/gitea/modules/setting"
|
||||||
api "code.gitea.io/gitea/modules/structs"
|
api "code.gitea.io/gitea/modules/structs"
|
||||||
secret_service "code.gitea.io/gitea/services/secrets"
|
secret_service "code.gitea.io/gitea/services/secrets"
|
||||||
|
|
||||||
@ -305,22 +306,23 @@ func pickTask(ctx context.Context, runner *bots_model.Runner) (*runnerv1.Task, b
|
|||||||
|
|
||||||
// TODO: more context in https://docs.github.com/cn/actions/learn-github-actions/contexts#github-context
|
// TODO: more context in https://docs.github.com/cn/actions/learn-github-actions/contexts#github-context
|
||||||
taskContext, _ := structpb.NewStruct(map[string]interface{}{
|
taskContext, _ := structpb.NewStruct(map[string]interface{}{
|
||||||
"event": event,
|
"event": event,
|
||||||
"run_id": fmt.Sprint(t.Job.ID),
|
"run_id": fmt.Sprint(t.Job.ID),
|
||||||
"run_number": fmt.Sprint(t.Job.Run.Index),
|
"run_number": fmt.Sprint(t.Job.Run.Index),
|
||||||
"run_attempt": fmt.Sprint(t.Job.Attempt),
|
"run_attempt": fmt.Sprint(t.Job.Attempt),
|
||||||
"actor": fmt.Sprint(t.Job.Run.TriggerUser.Name),
|
"actor": fmt.Sprint(t.Job.Run.TriggerUser.Name),
|
||||||
"repository": fmt.Sprint(t.Job.Run.Repo.OwnerName) + "/" + fmt.Sprint(t.Job.Run.Repo.Name),
|
"repository": fmt.Sprint(t.Job.Run.Repo.OwnerName) + "/" + fmt.Sprint(t.Job.Run.Repo.Name),
|
||||||
"event_name": fmt.Sprint(t.Job.Run.Event.Event()),
|
"event_name": fmt.Sprint(t.Job.Run.Event.Event()),
|
||||||
"sha": fmt.Sprint(t.Job.Run.CommitSHA),
|
"sha": fmt.Sprint(t.Job.Run.CommitSHA),
|
||||||
"ref": fmt.Sprint(t.Job.Run.Ref),
|
"ref": fmt.Sprint(t.Job.Run.Ref),
|
||||||
"ref_name": "",
|
"ref_name": "",
|
||||||
"ref_type": "",
|
"ref_type": "",
|
||||||
"head_ref": "",
|
"head_ref": "",
|
||||||
"base_ref": "",
|
"base_ref": "",
|
||||||
"token": t.Token,
|
"token": t.Token,
|
||||||
"repository_owner": fmt.Sprint(t.Job.Run.Repo.OwnerName),
|
"repository_owner": fmt.Sprint(t.Job.Run.Repo.OwnerName),
|
||||||
"retention_days": "",
|
"retention_days": "",
|
||||||
|
"gitea_default_bots_url": setting.Bots.DefaultBotsURL,
|
||||||
})
|
})
|
||||||
secrets := getSecretsOfTask(ctx, t)
|
secrets := getSecretsOfTask(ctx, t)
|
||||||
if _, ok := secrets["GITHUB_TOKEN"]; !ok {
|
if _, ok := secrets["GITHUB_TOKEN"]; !ok {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user