Support intepolation for env
of services
(#47)
Reviewed-on: https://gitea.com/gitea/act/pulls/47 Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: Zettat123 <zettat123@gmail.com> Co-committed-by: Zettat123 <zettat123@gmail.com>
This commit is contained in:
parent
8609522aa4
commit
e12252a43a
1 changed files with 7 additions and 3 deletions
|
@ -246,9 +246,13 @@ func (rc *RunContext) startJobContainer() common.Executor {
|
||||||
|
|
||||||
// add service containers
|
// add service containers
|
||||||
for name, spec := range rc.Run.Job().Services {
|
for name, spec := range rc.Run.Job().Services {
|
||||||
mergedEnv := envList
|
interpolatedEnvs := make(map[string]string, len(spec.Env))
|
||||||
for k, v := range spec.Env {
|
for k, v := range spec.Env {
|
||||||
mergedEnv = append(mergedEnv, fmt.Sprintf("%s=%s", k, v))
|
interpolatedEnvs[k] = rc.ExprEval.Interpolate(ctx, v)
|
||||||
|
}
|
||||||
|
envs := make([]string, 0, len(interpolatedEnvs))
|
||||||
|
for k, v := range interpolatedEnvs {
|
||||||
|
envs = append(envs, fmt.Sprintf("%s=%s", k, v))
|
||||||
}
|
}
|
||||||
serviceContainerName := createSimpleContainerName(rc.jobContainerName(), name)
|
serviceContainerName := createSimpleContainerName(rc.jobContainerName(), name)
|
||||||
c := container.NewContainer(&container.NewContainerInput{
|
c := container.NewContainer(&container.NewContainerInput{
|
||||||
|
@ -257,7 +261,7 @@ func (rc *RunContext) startJobContainer() common.Executor {
|
||||||
Image: spec.Image,
|
Image: spec.Image,
|
||||||
Username: username,
|
Username: username,
|
||||||
Password: password,
|
Password: password,
|
||||||
Env: mergedEnv,
|
Env: envs,
|
||||||
Mounts: map[string]string{
|
Mounts: map[string]string{
|
||||||
// TODO merge volumes
|
// TODO merge volumes
|
||||||
name: ext.ToContainerPath(rc.Config.Workdir),
|
name: ext.ToContainerPath(rc.Config.Workdir),
|
||||||
|
|
Loading…
Reference in a new issue