mirror of
https://code.forgejo.org/forgejo/runner.git
synced 2024-11-21 20:27:17 +03:00
Support bot site
This commit is contained in:
parent
bfcc6f56f3
commit
5fc35faf17
7 changed files with 20 additions and 23 deletions
|
@ -52,7 +52,7 @@ func runDaemon(ctx context.Context, envFile string) func(cmd *cobra.Command, arg
|
|||
runner := &runtime.Runner{
|
||||
Client: cli,
|
||||
Machine: cfg.Runner.Name,
|
||||
ForgeInstance: cfg.ForgeInstance,
|
||||
ForgeInstance: cfg.Client.Address,
|
||||
Environ: cfg.Runner.Environ,
|
||||
}
|
||||
|
||||
|
|
|
@ -15,12 +15,11 @@ import (
|
|||
type (
|
||||
// Config provides the system configuration.
|
||||
Config struct {
|
||||
Debug bool `envconfig:"GITEA_DEBUG"`
|
||||
Trace bool `envconfig:"GITEA_TRACE"`
|
||||
Client Client
|
||||
Runner Runner
|
||||
Platform Platform
|
||||
ForgeInstance string
|
||||
Debug bool `envconfig:"GITEA_DEBUG"`
|
||||
Trace bool `envconfig:"GITEA_TRACE"`
|
||||
Client Client
|
||||
Runner Runner
|
||||
Platform Platform
|
||||
}
|
||||
|
||||
Client struct {
|
||||
|
@ -72,7 +71,6 @@ func FromEnviron() (Config, error) {
|
|||
if runner.Address != "" {
|
||||
cfg.Client.Address = runner.Address
|
||||
}
|
||||
cfg.ForgeInstance = runner.ForgeInstance
|
||||
}
|
||||
|
||||
// runner config
|
||||
|
|
|
@ -7,10 +7,9 @@ const (
|
|||
|
||||
// Runner struct
|
||||
type Runner struct {
|
||||
ID int64 `json:"id"`
|
||||
UUID string `json:"uuid"`
|
||||
Name string `json:"name"`
|
||||
Token string `json:"token"`
|
||||
Address string `json:"address"`
|
||||
ForgeInstance string `json:"forge_instance"`
|
||||
ID int64 `json:"id"`
|
||||
UUID string `json:"uuid"`
|
||||
Name string `json:"name"`
|
||||
Token string `json:"token"`
|
||||
Address string `json:"address"`
|
||||
}
|
||||
|
|
2
go.mod
2
go.mod
|
@ -72,4 +72,4 @@ require (
|
|||
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
4
go.sum
|
@ -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.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk=
|
||||
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-20221108101106-28099ee68a88/go.mod h1:lpzib6X73FHLSaTqTakan1xcsCAVhlZvPSpLns7jkRo=
|
||||
gitea.com/gitea/act v0.0.0-20221116100712-3caee171b716 h1:wPFBAjfK5OFBruaX9BNSdPoRcVdEbsjviSpryVjFZjY=
|
||||
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/go.mod h1:hD8YwSHusjwjEEgubW6XFvnZuNhMZTHz6lwjfltEt/Y=
|
||||
github.com/Azure/azure-sdk-for-go v16.2.1+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc=
|
||||
|
|
|
@ -47,7 +47,6 @@ func (p *Register) Register(ctx context.Context, cfg config.Runner) (*core.Runne
|
|||
Name: resp.Msg.Runner.Name,
|
||||
Token: resp.Msg.Runner.Token,
|
||||
Address: p.Client.Address(),
|
||||
// ForgeInstance: resp.Msg.Runner.ForgeInstance, TODO: add me
|
||||
}
|
||||
|
||||
file, err := json.MarshalIndent(data, "", " ")
|
||||
|
|
|
@ -56,8 +56,7 @@ type TaskInput struct {
|
|||
noSkipCheckout bool
|
||||
// remoteName string
|
||||
|
||||
ForgeInstance string
|
||||
EnvFile string
|
||||
EnvFile string
|
||||
}
|
||||
|
||||
type Task struct {
|
||||
|
@ -73,7 +72,6 @@ func NewTask(forgeInstance string, buildID int64, client client.Client, runnerEn
|
|||
task := &Task{
|
||||
Input: &TaskInput{
|
||||
reuseContainers: false,
|
||||
ForgeInstance: forgeInstance,
|
||||
envs: runnerEnvs,
|
||||
noSkipCheckout: true,
|
||||
},
|
||||
|
@ -170,7 +168,9 @@ func (t *Task) Run(ctx context.Context, task *runnerv1.Task) error {
|
|||
token := getToken(task)
|
||||
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{
|
||||
Event: dataContext["event"].GetStructValue().AsMap(),
|
||||
|
@ -213,7 +213,7 @@ func (t *Task) Run(ctx context.Context, task *runnerv1.Task) error {
|
|||
ContainerArchitecture: input.containerArchitecture,
|
||||
ContainerDaemonSocket: input.containerDaemonSocket,
|
||||
UseGitIgnore: input.useGitIgnore,
|
||||
GitHubInstance: input.ForgeInstance,
|
||||
GitHubInstance: t.client.Address(),
|
||||
ContainerCapAdd: input.containerCapAdd,
|
||||
ContainerCapDrop: input.containerCapDrop,
|
||||
AutoRemove: input.autoRemove,
|
||||
|
@ -223,6 +223,7 @@ func (t *Task) Run(ctx context.Context, task *runnerv1.Task) error {
|
|||
PresetGitHubContext: preset,
|
||||
EventJSON: string(eventJSON),
|
||||
ContainerNamePrefix: fmt.Sprintf("gitea-task-%d", task.Id),
|
||||
DefaultActionInstance: dataContext["gitea_default_bots_url"].GetStringValue(),
|
||||
}
|
||||
r, err := runner.New(config)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in a new issue