add new envs
This commit is contained in:
parent
93e42d1465
commit
222b5100b6
|
@ -33,7 +33,7 @@ func initLogging(cfg config.Config) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func Execute(ctx context.Context) {
|
func Execute(ctx context.Context) {
|
||||||
task := runtime.NewTask("gitea", 0, nil)
|
task := runtime.NewTask("gitea", 0, nil, nil)
|
||||||
|
|
||||||
// ./act_runner
|
// ./act_runner
|
||||||
rootCmd := &cobra.Command{
|
rootCmd := &cobra.Command{
|
||||||
|
|
|
@ -75,9 +75,18 @@ func FromEnviron() (Config, error) {
|
||||||
cfg.ForgeInstance = runner.ForgeInstance
|
cfg.ForgeInstance = runner.ForgeInstance
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cfg.Client.Address = fmt.Sprintf(
|
||||||
|
"%s://%s",
|
||||||
|
cfg.Client.Proto,
|
||||||
|
cfg.Client.Host,
|
||||||
|
)
|
||||||
|
|
||||||
// runner config
|
// runner config
|
||||||
if cfg.Runner.Environ == nil {
|
if cfg.Runner.Environ == nil {
|
||||||
cfg.Runner.Environ = map[string]string{}
|
cfg.Runner.Environ = map[string]string{
|
||||||
|
"GITHUB_API_URL": cfg.Client.Address + "/api/v1",
|
||||||
|
"GITHUB_SERVER_URL": cfg.Client.Address,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if cfg.Runner.Name == "" {
|
if cfg.Runner.Name == "" {
|
||||||
cfg.Runner.Name, _ = os.Hostname()
|
cfg.Runner.Name, _ = os.Hostname()
|
||||||
|
@ -91,12 +100,6 @@ func FromEnviron() (Config, error) {
|
||||||
cfg.Platform.Arch = runtime.GOARCH
|
cfg.Platform.Arch = runtime.GOARCH
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg.Client.Address = fmt.Sprintf(
|
|
||||||
"%s://%s",
|
|
||||||
cfg.Client.Proto,
|
|
||||||
cfg.Client.Host,
|
|
||||||
)
|
|
||||||
|
|
||||||
if file := cfg.Runner.EnvFile; file != "" {
|
if file := cfg.Runner.EnvFile; file != "" {
|
||||||
envs, err := godotenv.Read(file)
|
envs, err := godotenv.Read(file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -49,5 +49,5 @@ func (s *Runner) Run(ctx context.Context, task *runnerv1.Task) error {
|
||||||
l.Info("update runner status to idle")
|
l.Info("update runner status to idle")
|
||||||
}()
|
}()
|
||||||
|
|
||||||
return NewTask(s.ForgeInstance, task.Id, s.Client).Run(ctx, task)
|
return NewTask(s.ForgeInstance, task.Id, s.Client, s.Environ).Run(ctx, task)
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ type TaskInput struct {
|
||||||
reuseContainers bool
|
reuseContainers bool
|
||||||
bindWorkdir bool
|
bindWorkdir bool
|
||||||
// secrets []string
|
// secrets []string
|
||||||
// envs []string
|
envs map[string]string
|
||||||
// platforms []string
|
// platforms []string
|
||||||
// dryrun bool
|
// dryrun bool
|
||||||
forcePull bool
|
forcePull bool
|
||||||
|
@ -69,11 +69,12 @@ type Task struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewTask creates a new task
|
// NewTask creates a new task
|
||||||
func NewTask(forgeInstance string, buildID int64, client client.Client) *Task {
|
func NewTask(forgeInstance string, buildID int64, client client.Client, runnerEnvs map[string]string) *Task {
|
||||||
task := &Task{
|
task := &Task{
|
||||||
Input: &TaskInput{
|
Input: &TaskInput{
|
||||||
reuseContainers: true,
|
reuseContainers: true,
|
||||||
ForgeInstance: forgeInstance,
|
ForgeInstance: forgeInstance,
|
||||||
|
envs: runnerEnvs,
|
||||||
},
|
},
|
||||||
BuildID: buildID,
|
BuildID: buildID,
|
||||||
|
|
||||||
|
@ -172,9 +173,10 @@ func (t *Task) Run(ctx context.Context, task *runnerv1.Task) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
token := getToken(task)
|
token := getToken(task)
|
||||||
log.Infof("task %v token is %v", task.Id, token)
|
|
||||||
|
|
||||||
dataContext := task.Context.Fields
|
dataContext := task.Context.Fields
|
||||||
|
|
||||||
|
log.Infof("task %v token is %v %v", task.Id, token, dataContext["repository"].GetStringValue())
|
||||||
|
|
||||||
preset := &model.GithubContext{
|
preset := &model.GithubContext{
|
||||||
Event: dataContext["event"].GetStructValue().AsMap(),
|
Event: dataContext["event"].GetStructValue().AsMap(),
|
||||||
RunID: dataContext["run_id"].GetStringValue(),
|
RunID: dataContext["run_id"].GetStringValue(),
|
||||||
|
@ -224,6 +226,7 @@ func (t *Task) Run(ctx context.Context, task *runnerv1.Task) error {
|
||||||
NoSkipCheckout: input.noSkipCheckout,
|
NoSkipCheckout: input.noSkipCheckout,
|
||||||
PresetGitHubContext: preset,
|
PresetGitHubContext: preset,
|
||||||
EventJSON: string(eventJSON),
|
EventJSON: string(eventJSON),
|
||||||
|
Env: t.Input.envs,
|
||||||
}
|
}
|
||||||
r, err := runner.New(config)
|
r, err := runner.New(config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue