Evaluate run-name field for workflows (#137)
To support https://github.com/go-gitea/gitea/pull/34301 Reviewed-on: https://gitea.com/gitea/act/pulls/137 Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: badhezi <zlilaharon@gmail.com> Co-committed-by: badhezi <zlilaharon@gmail.com>
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
|||||||
|
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
|
|
||||||
|
"github.com/nektos/act/pkg/exprparser"
|
||||||
"github.com/nektos/act/pkg/model"
|
"github.com/nektos/act/pkg/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -40,6 +41,10 @@ func Parse(content []byte, options ...ParseOption) ([]*SingleWorkflow, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("invalid jobs: %w", err)
|
return nil, fmt.Errorf("invalid jobs: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
evaluator := NewExpressionEvaluator(exprparser.NewInterpeter(&exprparser.EvaluationEnvironment{Github: pc.gitContext, Vars: pc.vars}, exprparser.Config{}))
|
||||||
|
workflow.RunName = evaluator.Interpolate(workflow.RunName)
|
||||||
|
|
||||||
for i, id := range ids {
|
for i, id := range ids {
|
||||||
job := jobs[i]
|
job := jobs[i]
|
||||||
matricxes, err := getMatrixes(origin.GetJob(id))
|
matricxes, err := getMatrixes(origin.GetJob(id))
|
||||||
@@ -65,6 +70,7 @@ func Parse(content []byte, options ...ParseOption) ([]*SingleWorkflow, error) {
|
|||||||
Env: workflow.Env,
|
Env: workflow.Env,
|
||||||
Defaults: workflow.Defaults,
|
Defaults: workflow.Defaults,
|
||||||
RawPermissions: workflow.RawPermissions,
|
RawPermissions: workflow.RawPermissions,
|
||||||
|
RunName: workflow.RunName,
|
||||||
}
|
}
|
||||||
if err := swf.SetJob(id, job); err != nil {
|
if err := swf.SetJob(id, job); err != nil {
|
||||||
return nil, fmt.Errorf("SetJob: %w", err)
|
return nil, fmt.Errorf("SetJob: %w", err)
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ type SingleWorkflow struct {
|
|||||||
RawJobs yaml.Node `yaml:"jobs,omitempty"`
|
RawJobs yaml.Node `yaml:"jobs,omitempty"`
|
||||||
Defaults Defaults `yaml:"defaults,omitempty"`
|
Defaults Defaults `yaml:"defaults,omitempty"`
|
||||||
RawPermissions yaml.Node `yaml:"permissions,omitempty"`
|
RawPermissions yaml.Node `yaml:"permissions,omitempty"`
|
||||||
|
RunName string `yaml:"run-name,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *SingleWorkflow) Job() (string, *Job) {
|
func (w *SingleWorkflow) Job() (string, *Job) {
|
||||||
|
|||||||
Reference in New Issue
Block a user