pkg/runner: add support to replace GitHub's env (#1197)
There might be use cases where users want to use GitHub's variables in the environment variables, which is a valid use case. This commits adds support for replacement of GitHub's env with GitHub's values. Signed-off-by: André Martins <aanm90@gmail.com>
This commit is contained in:
@@ -14,6 +14,7 @@ import (
|
||||
|
||||
"github.com/nektos/act/pkg/common"
|
||||
"github.com/nektos/act/pkg/container"
|
||||
"github.com/nektos/act/pkg/exprparser"
|
||||
"github.com/nektos/act/pkg/model"
|
||||
)
|
||||
|
||||
@@ -159,6 +160,14 @@ func (runner *runnerImpl) NewPlanExecutor(plan *model.Plan) common.Executor {
|
||||
if len(matrixes) > 1 {
|
||||
rc.Name = fmt.Sprintf("%s-%d", rc.Name, i+1)
|
||||
}
|
||||
// evaluate environment variables since they can contain
|
||||
// GitHub's special environment variables.
|
||||
for k, v := range rc.GetEnv() {
|
||||
valueEval, err := rc.ExprEval.evaluate(v, exprparser.DefaultStatusCheckNone)
|
||||
if err == nil {
|
||||
rc.Env[k] = fmt.Sprintf("%v", valueEval)
|
||||
}
|
||||
}
|
||||
if len(rc.String()) > maxJobNameLen {
|
||||
maxJobNameLen = len(rc.String())
|
||||
}
|
||||
|
Reference in New Issue
Block a user