-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Actions support workflow dispatch event #28163
Actions support workflow dispatch event #28163
Conversation
Well, the problem is, you can specify some user-supplied fields for workflow_dispatch, have you handled that case as well? |
I plan to implement a version similar to github, providing a form that allows users to fill in the env parameters of the workflow run, and these parameters can be configured in yaml. Hopefully I can complete it |
https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_dispatch |
I think it should be following now.
|
templates/repo/actions/list.tmpl
Outdated
@@ -76,6 +76,11 @@ | |||
</button> | |||
{{end}} | |||
</div> | |||
|
|||
{{if .AllowTriggerWorkflowDispatchEvent}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{{if .AllowTriggerWorkflowDispatchEvent}} | |
{{if .WorkflowDispatchConfig}} |
AllowTriggerWorkflowDispatchEvent
is unnecessary.
But WorkflowDispatch
or WorkflowDispatchConfig
should be improved,
return WorkflowDispatch{} when inputs are not defined.
return nil, when there are no workflow_dispatch in on
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AllowTriggerWorkflowDispatchEvent
is used to decide whether to display trigger button, and WorkflowDispatchConfig
is used to decide whether to process inputs;
it can also be triggered without inputs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When workflow_dispatch is defined, but inputs are not
→ workflowDispatchConfig = {}
→ workflowDispatchConfig != nil, let's display the notification
→ user click Run Workflow
→ workflowDispatchConfig.Inputs = nil, don't have inputs, don't show them
When workflow_dispatch and inputs are both defined
→ workflowDispatchConfig = nil
→ don't display the notification
But we should do some changes to WorkflowDispatchConfig
function.
WorkflowDispatchConfig
will return nil
when workflow_dispatch is defined, but inputs are not.
And this also causes a bug now, when workflow_dispatch is defined, but inputs are not, the notification will not display😕
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, yes, you are right; before, WorkflowDispatchConfig() always returned non-null, but now the behavior of parse has been modified. Use workflowDispatchConfig to determine whether to display the button or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for such a confusing scenario; I fixed it and the logic now is:
- workflow_dispatch is
not
defined, WorkflowDispatchConfig() returnnil
- workflow_dispatch is defined WorkflowDispatchConfig() return
non nil
, Whether theinput
is defined or not - inputs is not defined
WorkflowDispatch.Inputs
is nil
so,
WorkflowDispatchConfig
if exists, display button- When
.WorkflowDispatchConfig.Inputs
is nil,<range >
nothing happens
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ParseRawOn
is no longer needed
but, I think some modif still need to be made, workflow_dispatch is not defined, WorkflowDispatchConfig() return nil
var config WorkflowDispatch
node := val["workflow_dispatch"]
if !decodeNode(node, &config) {
return nil
}
return &config
change to
var config WorkflowDispatch
node, found := val["workflow_dispatch"]
if found && decodeNode(node, &config) {
return &config
}
return nil
I submitted a simpler PR to fix it: https://gitea.com/gitea/act/pulls/85
The previous PR 84 is no longer needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution.
ps: not only workflow_dispatch
, other events, e.g. workflow_call
, have some similar functions,
we can check them later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need do more changes in WorkflowDispatchConfig
.
if w.RawOn.Kind != yaml.MappingNode {
return nil
}
This is not correct. e.g. if I define this:
on: [push, workflow_dispatch]
w.RawOn.Kind
is yaml.SequenceNode
, and will return nil.
If I define this:
on: workflow_dispatch
w.RawOn.Kind
is yaml.ScalarNode
, and will return nil.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I think I will have some time to work on it next few days; btw, it seems that the On
function has the same problem, switch does not handle all types of kind
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I pushed a new commit to nektos/act#2123 and added a recursive function to handle nested SequenceNode. It can also support workflow_call. The following cases have been tested.
on: workflow_dispatch
on: [push, workflow_dispatch]
on:
- push
- workflow_dispatch
on:
push:
pull_request:
workflow_dispatch:
inputs:
logLevel:
description: 'Log level'
required: true
default: 'warning'
type: choice
options:
- info
- warning
- debug
I changed it to checkbox because it is more common throughout Gitea UI |
Also, putting the titles of the input fields is equally common in Gitea UI. This long form is just an example and shouldn't normally contain so many fields. We can make it wider, however, just to look better. |
Yes, wider is better. |
Co-authored-by: Denys Konovalov <[email protected]>
Co-authored-by: Denys Konovalov <[email protected]>
Thanks so much @pangliang !!! |
Please send a docs PR to https://gitea.com/gitea/docs |
* giteaofficial/main: add CfTurnstileSitekey context data to all captcha templates (go-gitea#31874) Add tag name in the commits list (go-gitea#31082) Fix actions notify bug (go-gitea#31866) Actions support workflow dispatch event (go-gitea#28163)
This reverts commit 36232b6.
Why has this feature been removed from 1.22.2 in the end ? |
@FireGhost this is part of 1.23, wait for release. |
fix #23668
My plan:
actions.list
method, if workflow is selected and IsAdmin, check whether the on event containsworkflow_dispatch
. If so, display aRun workflow
button to allow the user to manually trigger the run.required
input cannot be empty/actions/run
, and anactions.Run
method to handleWorkflowDispatchPayload
struct to pass the Webhook event payload to the runner when triggered, this payload carries theinputs
values and other fields, doc: workflow_dispatch payloadOther PRs
Workflow.WorkflowDispatchConfig()
method still return non-nil when workflow_dispatch is not defined. I submitted a PR https://gitea.com/gitea/act/pulls/85 to fix it. Still waiting for them to process.Behavior should be same with github, but may cause confusion. Here's a quick reminder.
only
trigger a workflow run if the workflow file ison the default branch
.Use workflow from
selects another branch