Support bot site

This commit is contained in:
Lunny Xiao 2022-11-16 18:08:12 +08:00 committed by Jason Song
parent bfcc6f56f3
commit 5fc35faf17
7 changed files with 20 additions and 23 deletions

View File

@ -52,7 +52,7 @@ func runDaemon(ctx context.Context, envFile string) func(cmd *cobra.Command, arg
runner := &runtime.Runner{ runner := &runtime.Runner{
Client: cli, Client: cli,
Machine: cfg.Runner.Name, Machine: cfg.Runner.Name,
ForgeInstance: cfg.ForgeInstance, ForgeInstance: cfg.Client.Address,
Environ: cfg.Runner.Environ, Environ: cfg.Runner.Environ,
} }

View File

@ -20,7 +20,6 @@ type (
Client Client Client Client
Runner Runner Runner Runner
Platform Platform Platform Platform
ForgeInstance string
} }
Client struct { Client struct {
@ -72,7 +71,6 @@ func FromEnviron() (Config, error) {
if runner.Address != "" { if runner.Address != "" {
cfg.Client.Address = runner.Address cfg.Client.Address = runner.Address
} }
cfg.ForgeInstance = runner.ForgeInstance
} }
// runner config // runner config

View File

@ -12,5 +12,4 @@ type Runner struct {
Name string `json:"name"` Name string `json:"name"`
Token string `json:"token"` Token string `json:"token"`
Address string `json:"address"` Address string `json:"address"`
ForgeInstance string `json:"forge_instance"`
} }

2
go.mod
View File

@ -72,4 +72,4 @@ require (
gopkg.in/yaml.v3 v3.0.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect
) )
replace github.com/nektos/act => gitea.com/gitea/act v0.0.0-20221108101106-28099ee68a88 replace github.com/nektos/act => gitea.com/gitea/act v0.0.0-20221116100712-3caee171b716

4
go.sum
View File

@ -23,8 +23,8 @@ cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiy
cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos=
cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
gitea.com/gitea/act v0.0.0-20221108101106-28099ee68a88 h1:pfeGhadGGQbQuXqIgi/C6NQ+VopNEkHayz49IgANPAg= gitea.com/gitea/act v0.0.0-20221116100712-3caee171b716 h1:wPFBAjfK5OFBruaX9BNSdPoRcVdEbsjviSpryVjFZjY=
gitea.com/gitea/act v0.0.0-20221108101106-28099ee68a88/go.mod h1:lpzib6X73FHLSaTqTakan1xcsCAVhlZvPSpLns7jkRo= gitea.com/gitea/act v0.0.0-20221116100712-3caee171b716/go.mod h1:lpzib6X73FHLSaTqTakan1xcsCAVhlZvPSpLns7jkRo=
gitea.com/gitea/proto-go v0.0.0-20221028125601-35c4f6b05835 h1:27PhT7Nli/pgRo1bDYVZ+hlCKuF9cfFuo+y9muaPVJY= gitea.com/gitea/proto-go v0.0.0-20221028125601-35c4f6b05835 h1:27PhT7Nli/pgRo1bDYVZ+hlCKuF9cfFuo+y9muaPVJY=
gitea.com/gitea/proto-go v0.0.0-20221028125601-35c4f6b05835/go.mod h1:hD8YwSHusjwjEEgubW6XFvnZuNhMZTHz6lwjfltEt/Y= gitea.com/gitea/proto-go v0.0.0-20221028125601-35c4f6b05835/go.mod h1:hD8YwSHusjwjEEgubW6XFvnZuNhMZTHz6lwjfltEt/Y=
github.com/Azure/azure-sdk-for-go v16.2.1+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= github.com/Azure/azure-sdk-for-go v16.2.1+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc=

View File

@ -47,7 +47,6 @@ func (p *Register) Register(ctx context.Context, cfg config.Runner) (*core.Runne
Name: resp.Msg.Runner.Name, Name: resp.Msg.Runner.Name,
Token: resp.Msg.Runner.Token, Token: resp.Msg.Runner.Token,
Address: p.Client.Address(), Address: p.Client.Address(),
// ForgeInstance: resp.Msg.Runner.ForgeInstance, TODO: add me
} }
file, err := json.MarshalIndent(data, "", " ") file, err := json.MarshalIndent(data, "", " ")

View File

@ -56,7 +56,6 @@ type TaskInput struct {
noSkipCheckout bool noSkipCheckout bool
// remoteName string // remoteName string
ForgeInstance string
EnvFile string EnvFile string
} }
@ -73,7 +72,6 @@ func NewTask(forgeInstance string, buildID int64, client client.Client, runnerEn
task := &Task{ task := &Task{
Input: &TaskInput{ Input: &TaskInput{
reuseContainers: false, reuseContainers: false,
ForgeInstance: forgeInstance,
envs: runnerEnvs, envs: runnerEnvs,
noSkipCheckout: true, noSkipCheckout: true,
}, },
@ -170,7 +168,9 @@ func (t *Task) Run(ctx context.Context, task *runnerv1.Task) error {
token := getToken(task) token := getToken(task)
dataContext := task.Context.Fields dataContext := task.Context.Fields
log.Infof("task %v token is %v %v", task.Id, token, dataContext["repository"].GetStringValue()) log.Infof("task %v repo is %v %v %v", task.Id, dataContext["repository"].GetStringValue(),
dataContext["gitea_default_bots_url"].GetStringValue(),
t.client.Address())
preset := &model.GithubContext{ preset := &model.GithubContext{
Event: dataContext["event"].GetStructValue().AsMap(), Event: dataContext["event"].GetStructValue().AsMap(),
@ -213,7 +213,7 @@ func (t *Task) Run(ctx context.Context, task *runnerv1.Task) error {
ContainerArchitecture: input.containerArchitecture, ContainerArchitecture: input.containerArchitecture,
ContainerDaemonSocket: input.containerDaemonSocket, ContainerDaemonSocket: input.containerDaemonSocket,
UseGitIgnore: input.useGitIgnore, UseGitIgnore: input.useGitIgnore,
GitHubInstance: input.ForgeInstance, GitHubInstance: t.client.Address(),
ContainerCapAdd: input.containerCapAdd, ContainerCapAdd: input.containerCapAdd,
ContainerCapDrop: input.containerCapDrop, ContainerCapDrop: input.containerCapDrop,
AutoRemove: input.autoRemove, AutoRemove: input.autoRemove,
@ -223,6 +223,7 @@ func (t *Task) Run(ctx context.Context, task *runnerv1.Task) error {
PresetGitHubContext: preset, PresetGitHubContext: preset,
EventJSON: string(eventJSON), EventJSON: string(eventJSON),
ContainerNamePrefix: fmt.Sprintf("gitea-task-%d", task.Id), ContainerNamePrefix: fmt.Sprintf("gitea-task-%d", task.Id),
DefaultActionInstance: dataContext["gitea_default_bots_url"].GetStringValue(),
} }
r, err := runner.New(config) r, err := runner.New(config)
if err != nil { if err != nil {