@@ -44,16 +44,16 @@ func EnableOrDisableWorkflow(ctx *context.APIContext, workflowID string, isEnabl
4444 return repo_model .UpdateRepoUnit (ctx , cfgUnit )
4545}
4646
47- func DispatchActionWorkflow (ctx reqctx.RequestContext , doer * user_model.User , repo * repo_model.Repository , gitRepo * git.Repository , workflowID , ref string , processInputs func (model * model.WorkflowDispatch , inputs map [string ]any ) error ) error {
47+ func DispatchActionWorkflow (ctx reqctx.RequestContext , doer * user_model.User , repo * repo_model.Repository , gitRepo * git.Repository , workflowID , ref string , processInputs func (model * model.WorkflowDispatch , inputs map [string ]any ) error ) ( runID int64 , _ error ) {
4848 if workflowID == "" {
49- return util .ErrorWrapTranslatable (
49+ return 0 , util .ErrorWrapTranslatable (
5050 util .NewNotExistErrorf ("workflowID is empty" ),
5151 "actions.workflow.not_found" , workflowID ,
5252 )
5353 }
5454
5555 if ref == "" {
56- return util .ErrorWrapTranslatable (
56+ return 0 , util .ErrorWrapTranslatable (
5757 util .NewNotExistErrorf ("ref is empty" ),
5858 "form.target_ref_not_exist" , ref ,
5959 )
@@ -63,7 +63,7 @@ func DispatchActionWorkflow(ctx reqctx.RequestContext, doer *user_model.User, re
6363 cfgUnit := repo .MustGetUnit (ctx , unit .TypeActions )
6464 cfg := cfgUnit .ActionsConfig ()
6565 if cfg .IsWorkflowDisabled (workflowID ) {
66- return util .ErrorWrapTranslatable (
66+ return 0 , util .ErrorWrapTranslatable (
6767 util .NewPermissionDeniedErrorf ("workflow is disabled" ),
6868 "actions.workflow.disabled" ,
6969 )
@@ -82,7 +82,7 @@ func DispatchActionWorkflow(ctx reqctx.RequestContext, doer *user_model.User, re
8282 runTargetCommit , err = gitRepo .GetBranchCommit (ref )
8383 }
8484 if err != nil {
85- return util .ErrorWrapTranslatable (
85+ return 0 , util .ErrorWrapTranslatable (
8686 util .NewNotExistErrorf ("ref %q doesn't exist" , ref ),
8787 "form.target_ref_not_exist" , ref ,
8888 )
@@ -91,7 +91,7 @@ func DispatchActionWorkflow(ctx reqctx.RequestContext, doer *user_model.User, re
9191 // get workflow entry from runTargetCommit
9292 _ , entries , err := actions .ListWorkflows (runTargetCommit )
9393 if err != nil {
94- return err
94+ return 0 , err
9595 }
9696
9797 // find workflow from commit
@@ -122,20 +122,20 @@ func DispatchActionWorkflow(ctx reqctx.RequestContext, doer *user_model.User, re
122122 }
123123
124124 if entry == nil {
125- return util .ErrorWrapTranslatable (
125+ return 0 , util .ErrorWrapTranslatable (
126126 util .NewNotExistErrorf ("workflow %q doesn't exist" , workflowID ),
127127 "actions.workflow.not_found" , workflowID ,
128128 )
129129 }
130130
131131 content , err := actions .GetContentFromEntry (entry )
132132 if err != nil {
133- return err
133+ return 0 , err
134134 }
135135
136136 singleWorkflow := & jobparser.SingleWorkflow {}
137137 if err := yaml .Unmarshal (content , singleWorkflow ); err != nil {
138- return fmt .Errorf ("failed to unmarshal workflow content: %w" , err )
138+ return 0 , fmt .Errorf ("failed to unmarshal workflow content: %w" , err )
139139 }
140140 // get inputs from post
141141 workflow := & model.Workflow {
@@ -144,7 +144,7 @@ func DispatchActionWorkflow(ctx reqctx.RequestContext, doer *user_model.User, re
144144 inputsWithDefaults := make (map [string ]any )
145145 if workflowDispatch := workflow .WorkflowDispatchConfig (); workflowDispatch != nil {
146146 if err = processInputs (workflowDispatch , inputsWithDefaults ); err != nil {
147- return err
147+ return 0 , err
148148 }
149149 }
150150
@@ -161,13 +161,13 @@ func DispatchActionWorkflow(ctx reqctx.RequestContext, doer *user_model.User, re
161161
162162 var eventPayload []byte
163163 if eventPayload , err = workflowDispatchPayload .JSONPayload (); err != nil {
164- return fmt .Errorf ("JSONPayload: %w" , err )
164+ return 0 , fmt .Errorf ("JSONPayload: %w" , err )
165165 }
166166 run .EventPayload = string (eventPayload )
167167
168168 // Insert the action run and its associated jobs into the database
169169 if err := PrepareRunAndInsert (ctx , content , run , inputsWithDefaults ); err != nil {
170- return fmt .Errorf ("PrepareRun: %w" , err )
170+ return 0 , fmt .Errorf ("PrepareRun: %w" , err )
171171 }
172- return nil
172+ return run . ID , nil
173173}
0 commit comments