Skip to content

Commit 9924aea

Browse files
badhezilunny
authored andcommitted
Evaluate run-name field for workflows (#137)
To support go-gitea/gitea#34301 Reviewed-on: https://gitea.com/gitea/act/pulls/137 Reviewed-by: Lunny Xiao <[email protected]> Co-authored-by: badhezi <[email protected]> Co-committed-by: badhezi <[email protected]>
1 parent 65c232c commit 9924aea

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

pkg/jobparser/jobparser.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88

99
"gopkg.in/yaml.v3"
1010

11+
"github.com/nektos/act/pkg/exprparser"
1112
"github.com/nektos/act/pkg/model"
1213
)
1314

@@ -40,6 +41,10 @@ func Parse(content []byte, options ...ParseOption) ([]*SingleWorkflow, error) {
4041
if err != nil {
4142
return nil, fmt.Errorf("invalid jobs: %w", err)
4243
}
44+
45+
evaluator := NewExpressionEvaluator(exprparser.NewInterpeter(&exprparser.EvaluationEnvironment{Github: pc.gitContext, Vars: pc.vars}, exprparser.Config{}))
46+
workflow.RunName = evaluator.Interpolate(workflow.RunName)
47+
4348
for i, id := range ids {
4449
job := jobs[i]
4550
matricxes, err := getMatrixes(origin.GetJob(id))
@@ -65,6 +70,7 @@ func Parse(content []byte, options ...ParseOption) ([]*SingleWorkflow, error) {
6570
Env: workflow.Env,
6671
Defaults: workflow.Defaults,
6772
RawPermissions: workflow.RawPermissions,
73+
RunName: workflow.RunName,
6874
}
6975
if err := swf.SetJob(id, job); err != nil {
7076
return nil, fmt.Errorf("SetJob: %w", err)

pkg/jobparser/model.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ type SingleWorkflow struct {
1616
RawJobs yaml.Node `yaml:"jobs,omitempty"`
1717
Defaults Defaults `yaml:"defaults,omitempty"`
1818
RawPermissions yaml.Node `yaml:"permissions,omitempty"`
19+
RunName string `yaml:"run-name,omitempty"`
1920
}
2021

2122
func (w *SingleWorkflow) Job() (string, *Job) {

0 commit comments

Comments
 (0)