-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Open
Labels
issue/needs-feedbackFor bugs, we need more details. For features, the feature must be described in more detailFor bugs, we need more details. For features, the feature must be described in more detailtopic/gitea-actionsrelated to the actions of Gitearelated to the actions of Giteatype/proposalThe new feature has not been accepted yet but needs to be discussed first.The new feature has not been accepted yet but needs to be discussed first.
Description
Feature Description
Currently, if you upload a YAML file into the .gitea/workflows folder, it automatically starts a build on each commit.
It would be nice if there was a config option to prevent this from happening so that builds could be triggered manually via the UI or in code by the API.
I have forked the code and patched this method for now - but it would be nice to have the feature built in maybe?
Original File: /modules/actions/workflows.go
func DetectWorkflows(
gitRepo *git.Repository,
commit *git.Commit,
triggedEvent webhook_module.HookEventType,
payload api.Payloader,
detectSchedule bool,
) ([]*DetectedWorkflow, []*DetectedWorkflow, error) {
_, entries, err := ListWorkflows(commit)
if err != nil {
return nil, nil, err
}
workflows := make([]*DetectedWorkflow, 0, len(entries))
schedules := make([]*DetectedWorkflow, 0, len(entries))
for _, entry := range entries {
content, err := GetContentFromEntry(entry)
if err != nil {
return nil, nil, err
}
// one workflow may have multiple events
events, err := GetEventsFromContent(content)
if err != nil {
log.Warn("ignore invalid workflow %q: %v", entry.Name(), err)
continue
}
for _, evt := range events {
log.Trace("detect workflow %q for event %#v matching %q", entry.Name(), evt, triggedEvent)
// preserve scheduled workflows if requested
if evt.IsSchedule() {
if detectSchedule {
dwf := &DetectedWorkflow{
EntryName: entry.Name(),
TriggerEvent: evt,
Content: content,
}
schedules = append(schedules, dwf)
}
continue
}
// only allow manual workflow_dispatch events
if evt.Name == "workflow_dispatch" {
dwf := &DetectedWorkflow{
EntryName: entry.Name(),
TriggerEvent: evt,
Content: content,
}
workflows = append(workflows, dwf)
}
}
}
return workflows, schedules, nil
}
Screenshots
No response
Metadata
Metadata
Assignees
Labels
issue/needs-feedbackFor bugs, we need more details. For features, the feature must be described in more detailFor bugs, we need more details. For features, the feature must be described in more detailtopic/gitea-actionsrelated to the actions of Gitearelated to the actions of Giteatype/proposalThe new feature has not been accepted yet but needs to be discussed first.The new feature has not been accepted yet but needs to be discussed first.