mirror of https://github.com/go-gitea/gitea
workflow_dispatch support inputs config
This commit is contained in:
parent
8eb79f3741
commit
d973fc1765
2
go.mod
2
go.mod
|
@ -302,7 +302,7 @@ replace github.com/hashicorp/go-version => github.com/6543/go-version v1.3.1
|
|||
|
||||
replace github.com/shurcooL/vfsgen => github.com/lunny/vfsgen v0.0.0-20220105142115-2c99e1ffdfa0
|
||||
|
||||
replace github.com/nektos/act => gitea.com/gitea/act v0.2.51
|
||||
replace github.com/nektos/act => gitea.com/pangliang/act v0.251.2-0.20231129053409-6a00b5cb3ceb
|
||||
|
||||
replace github.com/gorilla/feeds => github.com/yardenshoham/feeds v0.0.0-20240110072658-f3d0c21c0bd5
|
||||
|
||||
|
|
2
go.sum
2
go.sum
|
@ -63,6 +63,8 @@ gitea.com/lunny/dingtalk_webhook v0.0.0-20171025031554-e3534c89ef96 h1:+wWBi6Qfr
|
|||
gitea.com/lunny/dingtalk_webhook v0.0.0-20171025031554-e3534c89ef96/go.mod h1:VyMQP6ue6MKHM8UsOXfNfuMKD0oSAWZdXVcpHIN2yaY=
|
||||
gitea.com/lunny/levelqueue v0.4.2-0.20230414023320-3c0159fe0fe4 h1:IFT+hup2xejHqdhS7keYWioqfmxdnfblFDTGoOwcZ+o=
|
||||
gitea.com/lunny/levelqueue v0.4.2-0.20230414023320-3c0159fe0fe4/go.mod h1:HBqmLbz56JWpfEGG0prskAV97ATNRoj5LDmPicD22hU=
|
||||
gitea.com/pangliang/act v0.251.2-0.20231129053409-6a00b5cb3ceb h1:l1Jlxn7D6J+VfoP3R4F1IjxojZ7GEu2+tKeCet5HBkk=
|
||||
gitea.com/pangliang/act v0.251.2-0.20231129053409-6a00b5cb3ceb/go.mod h1:YthlRq0FUQIzgfJ3ZWvCvVq3I3VsC9s2NYQ9b2Uxccs=
|
||||
gitea.com/xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a h1:lSA0F4e9A2NcQSqGqTOXqu2aRi/XEQxDCBwM8yJtE6s=
|
||||
gitea.com/xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a/go.mod h1:EXuID2Zs0pAQhH8yz+DNjUbjppKQzKFAn28TMYPB6IU=
|
||||
github.com/42wim/sshsig v0.0.0-20211121163825-841cf5bbc121 h1:r3qt8PCHnfjOv9PN3H+XXKmDA1dfFMIN1AislhlA/ps=
|
||||
|
|
|
@ -3594,6 +3594,9 @@ workflow.disable_success = Workflow '%s' disabled successfully.
|
|||
workflow.enable = Enable Workflow
|
||||
workflow.enable_success = Workflow '%s' enabled successfully.
|
||||
workflow.disabled = Workflow is disabled.
|
||||
workflow.run = Run Workflow
|
||||
workflow.not_found = Workflow '%s' not found.
|
||||
workflow.run_success = Workflow '%s' run successfully.
|
||||
|
||||
need_approval_desc = Need approval to run workflows for fork pull request.
|
||||
|
||||
|
|
|
@ -3583,6 +3583,9 @@ workflow.disable_success=工作流 '%s' 已成功禁用。
|
|||
workflow.enable=启用工作流
|
||||
workflow.enable_success=工作流 '%s' 已成功启用。
|
||||
workflow.disabled=工作流已禁用。
|
||||
workflow.run=运行工作流
|
||||
workflow.not_found=工作流 '%s' 不存在。
|
||||
workflow.run_success=工作流 '%s' 触发成功。
|
||||
|
||||
need_approval_desc=该工作流由派生仓库的合并请求所触发,需要批准方可运行。
|
||||
|
||||
|
|
|
@ -139,6 +139,7 @@ func List(ctx *context.Context) {
|
|||
for _, event := range events {
|
||||
if event.Name == webhook_module.HookEventWorkflowDispatch.Event() {
|
||||
ctx.Data["AllowTriggerWorkflowDispatchEvent"] = true
|
||||
ctx.Data["WorkflowDispatchConfig"] = event.WorkflowDispatch()
|
||||
break
|
||||
}
|
||||
}
|
||||
|
|
|
@ -680,6 +680,9 @@ func disableOrEnableWorkflowFile(ctx *context_module.Context, isEnable bool) {
|
|||
}
|
||||
|
||||
func Run(ctx *context_module.Context) {
|
||||
redirectURL := fmt.Sprintf("%s/actions?workflow=%s&actor=%s&status=%s", ctx.Repo.RepoLink, url.QueryEscape(ctx.FormString("workflow")),
|
||||
url.QueryEscape(ctx.FormString("actor")), url.QueryEscape(ctx.FormString("status")))
|
||||
|
||||
workflow := ctx.FormString("workflow")
|
||||
if len(workflow) == 0 {
|
||||
ctx.ServerError("workflow", nil)
|
||||
|
@ -690,7 +693,8 @@ func Run(ctx *context_module.Context) {
|
|||
cfgUnit := ctx.Repo.Repository.MustGetUnit(ctx, unit.TypeActions)
|
||||
cfg := cfgUnit.ActionsConfig()
|
||||
if cfg.IsWorkflowDisabled(workflow) {
|
||||
ctx.JSONError(ctx.Locale.Tr("actions.workflow.disabled"))
|
||||
ctx.Flash.Error(ctx.Tr("actions.workflow.disabled", workflow))
|
||||
ctx.Redirect(redirectURL)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -724,7 +728,8 @@ func Run(ctx *context_module.Context) {
|
|||
}
|
||||
|
||||
if dwf == nil {
|
||||
ctx.JSONError(ctx.Locale.Tr("actions.workflow.not_found"))
|
||||
ctx.Flash.Error(ctx.Tr("actions.workflow.not_found", workflow))
|
||||
ctx.Redirect(redirectURL)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -759,6 +764,18 @@ func Run(ctx *context_module.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
for _, wf := range workflows {
|
||||
if wf.Env == nil {
|
||||
wf.Env = make(map[string]string)
|
||||
}
|
||||
for k, v := range ctx.Req.PostForm {
|
||||
if k == "_csrf" || len(v) == 0 || v[0] == "" {
|
||||
continue
|
||||
}
|
||||
wf.Env[k] = v[0]
|
||||
}
|
||||
}
|
||||
|
||||
// Insert the action run and its associated jobs into the database
|
||||
if err := actions_model.InsertRun(ctx, run, workflows); err != nil {
|
||||
ctx.ServerError("workflow", err)
|
||||
|
@ -771,7 +788,6 @@ func Run(ctx *context_module.Context) {
|
|||
}
|
||||
actions_service.CreateCommitStatus(ctx, alljobs...)
|
||||
|
||||
redirectURL := fmt.Sprintf("%s/actions?workflow=%s&actor=%s&status=%s", ctx.Repo.RepoLink, url.QueryEscape(workflow),
|
||||
url.QueryEscape(ctx.FormString("actor")), url.QueryEscape(ctx.FormString("status")))
|
||||
ctx.JSONRedirect(redirectURL)
|
||||
ctx.Flash.Success(ctx.Tr("actions.workflow.run_success", workflow))
|
||||
ctx.Redirect(redirectURL)
|
||||
}
|
||||
|
|
|
@ -75,11 +75,12 @@
|
|||
</div>
|
||||
</button>
|
||||
{{end}}
|
||||
|
||||
{{if .AllowTriggerWorkflowDispatchEvent}}
|
||||
<button class="ui basic small compact button gt-mr-0 link-action" data-url="{{$.Link}}/run?workflow={{$.CurWorkflow}}&actor={{.CurActor}}&status={{$.CurStatus}}">{{ctx.Locale.Tr "Run workflow"}}</button>
|
||||
{{end}}
|
||||
</div>
|
||||
|
||||
{{if .AllowTriggerWorkflowDispatchEvent}}
|
||||
{{template "repo/actions/workflow_dispatch" .}}
|
||||
{{end}}
|
||||
|
||||
{{template "repo/actions/runs_list" .}}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
<div class="ui ignored info message">
|
||||
This workflow has a workflow_dispatch event trigger.
|
||||
<button class="ui right floated mini button" onclick="$('#runWorkflowDispatchModal').modal('show');">{{ctx.Locale.Tr "actions.workflow.run"}}{{svg "octicon-triangle-down" 14 "dropdown icon"}}</button>
|
||||
</div>
|
||||
<div id="runWorkflowDispatchModal" class="ui mini modal">
|
||||
<div class="content">
|
||||
<form class="ui form" action="{{$.Link}}/run?workflow={{$.CurWorkflow}}&actor={{$.CurActor}}&status={{.Status}}" method="post">
|
||||
{{.CsrfTokenHtml}}
|
||||
{{if .WorkflowDispatchConfig}}
|
||||
{{range $key, $item := .WorkflowDispatchConfig.Inputs}}
|
||||
<div class="ui field {{if .Required}}required{{end}}">
|
||||
<label>{{$key}} :</label>
|
||||
{{if eq .Type "choice"}}
|
||||
<select class="ui fluid dropdown" name="{{$key}}">
|
||||
{{range .Options}}
|
||||
<option value="{{.}}" {{if eq $item.Default .}}selected{{end}} >{{.}}</option>
|
||||
{{end}}
|
||||
</select>
|
||||
<span class="help">{{.Description}}</span>
|
||||
{{else if eq .Type "boolean"}}
|
||||
<div class="ui toggle checkbox">
|
||||
<input type="checkbox" name="{{$key}}" {{if eq .Default "true"}}checked{{end}}>
|
||||
<label class="help">{{.Description}}</label>
|
||||
</div>
|
||||
{{else}}
|
||||
<input name="{{$key}}" value="{{.Default}}">
|
||||
<span class="help">{{.Description}}</span>
|
||||
{{end}}
|
||||
</div>
|
||||
{{end}}
|
||||
{{end}}
|
||||
<button class="ui tiny blue button">Submit</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
Loading…
Reference in New Issue