@@ -28,9 +28,7 @@ import (
28
28
webhook_module "code.gitea.io/gitea/modules/webhook"
29
29
"code.gitea.io/gitea/services/convert"
30
30
notify_service "code.gitea.io/gitea/services/notify"
31
- "gopkg.in/yaml.v3"
32
31
33
- "github.com/nektos/act/pkg/exprparser"
34
32
"github.com/nektos/act/pkg/jobparser"
35
33
"github.com/nektos/act/pkg/model"
36
34
)
@@ -318,7 +316,9 @@ func handleWorkflows(
318
316
Status : actions_model .StatusWaiting ,
319
317
}
320
318
321
- if err := evaluateExpressionsForRun (run , dwf ); err != nil {
319
+ if runName , err := parseRunName (run , dwf ); err == nil {
320
+ run .Title = runName
321
+ } else {
322
322
log .Error ("evaluateExpressionsForRun: %v" , err )
323
323
continue
324
324
}
@@ -517,9 +517,11 @@ func handleSchedules(
517
517
run := & actions_model.ActionSchedule {
518
518
Title : strings .SplitN (commit .CommitMessage , "\n " , 2 )[0 ],
519
519
RepoID : input .Repo .ID ,
520
+ Repo : input .Repo ,
520
521
OwnerID : input .Repo .OwnerID ,
521
522
WorkflowID : dwf .EntryName ,
522
523
TriggerUserID : user_model .ActionsUserID ,
524
+ TriggerUser : user_model .NewActionsUser (),
523
525
Ref : ref ,
524
526
CommitSHA : commit .ID .String (),
525
527
Event : input .Event ,
@@ -528,8 +530,10 @@ func handleSchedules(
528
530
Content : dwf .Content ,
529
531
}
530
532
531
- if runName , err := parseRunNameFromDetectedWorkflow ( dwf ); err == nil {
533
+ if runName , err := parseRunName ( run . ToActionRun (), dwf ); err == nil {
532
534
run .Title = runName
535
+ } else {
536
+ log .Error ("ParseRunName: %v" , err )
533
537
}
534
538
535
539
crons = append (crons , run )
@@ -571,55 +575,23 @@ func DetectAndHandleSchedules(ctx context.Context, repo *repo_model.Repository)
571
575
return handleSchedules (ctx , scheduleWorkflows , commit , notifyInput , repo .DefaultBranch )
572
576
}
573
577
574
- func newExpressionEvaluatorForRun (r * actions_model.ActionRun ) ( * jobparser. ExpressionEvaluator , error ) {
578
+ func parseRunName (r * actions_model.ActionRun , w * actions_module. DetectedWorkflow ) ( string , error ) {
575
579
ghCtx := & model.GithubContext {}
576
580
gitCtx := GenerateGiteaContext (r , nil )
577
581
578
582
gitCtxRaw , err := json .Marshal (gitCtx )
579
583
if err != nil {
580
584
log .Error ("NewInterpolatorForRun: %v" , err )
581
- return nil , err
585
+ return "" , err
582
586
}
583
587
584
588
err = json .Unmarshal (gitCtxRaw , ghCtx )
585
589
if err != nil {
586
590
log .Error ("NewInterpolatorForRun: %v" , err )
587
- return nil , err
588
- }
589
-
590
- interp := exprparser .NewInterpeter (& exprparser.EvaluationEnvironment {Github : ghCtx }, exprparser.Config {})
591
- ee := jobparser .NewExpressionEvaluator (interp )
592
- return ee , nil
593
- }
594
-
595
- func parseRunNameFromDetectedWorkflow (w * actions_module.DetectedWorkflow ) (string , error ) {
596
- var data map [string ]any
597
- var value string
598
-
599
- if err := yaml .Unmarshal (w .Content , & data ); err != nil {
600
- log .Error ("parseRunNameFromDetectedWorkflow: %v" , err )
601
591
return "" , err
602
592
}
603
593
604
- if v , ok := data ["run-name" ]; ok {
605
- value = v .(string )
606
- } else {
607
- return "" , fmt .Errorf ("run-name not found in workflow" )
608
- }
609
-
610
- return value , nil
611
- }
612
-
613
- func evaluateExpressionsForRun (r * actions_model.ActionRun , w * actions_module.DetectedWorkflow ) error {
614
- if runName , err := parseRunNameFromDetectedWorkflow (w ); err == nil {
615
- ee , err := newExpressionEvaluatorForRun (r )
616
- if err != nil {
617
- log .Error ("newExpressionEvaluatorForRun: %v" , err )
618
- return err
619
- }
620
- r .Title = ee .Interpolate (runName )
621
- } else {
622
- log .Error ("parseRunNameFromDetectedWorkflow: %v" , err )
623
- }
624
- return nil
594
+ title , _ := jobparser .ParseRunName (w .Content , jobparser .WithGitContext (ghCtx ))
595
+ log .Info ("title: %s" , title )
596
+ return title , nil
625
597
}
0 commit comments