mirror of
https://code.forgejo.org/forgejo/runner.git
synced 2025-08-06 17:40:58 +00:00
feat(workflow): support schedule event (#4)
fix https://gitea.com/gitea/act/issues/3 Signed-off-by: Bo-Yi.Wu <appleboy.tw@gmail.com> Co-authored-by: Bo-Yi.Wu <appleboy.tw@gmail.com> Reviewed-on: https://gitea.com/gitea/act/pulls/4
This commit is contained in:
parent
1ef04e7b8d
commit
8b8dfdb042
2 changed files with 107 additions and 1 deletions
|
@ -67,6 +67,30 @@ func (w *Workflow) OnEvent(event string) interface{} {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (w *Workflow) OnSchedule() []string {
|
||||
schedules := w.OnEvent("schedule")
|
||||
if schedules == nil {
|
||||
return []string{}
|
||||
}
|
||||
|
||||
switch val := schedules.(type) {
|
||||
case []interface{}:
|
||||
allSchedules := []string{}
|
||||
for _, v := range val {
|
||||
for k, cron := range v.(map[string]interface{}) {
|
||||
if k != "cron" {
|
||||
continue
|
||||
}
|
||||
allSchedules = append(allSchedules, cron.(string))
|
||||
}
|
||||
}
|
||||
return allSchedules
|
||||
default:
|
||||
}
|
||||
|
||||
return []string{}
|
||||
}
|
||||
|
||||
type WorkflowDispatchInput struct {
|
||||
Description string `yaml:"description"`
|
||||
Required bool `yaml:"required"`
|
||||
|
@ -487,7 +511,7 @@ func (s *Step) GetEnv() map[string]string {
|
|||
func (s *Step) ShellCommand() string {
|
||||
shellCommand := ""
|
||||
|
||||
//Reference: https://github.com/actions/runner/blob/8109c962f09d9acc473d92c595ff43afceddb347/src/Runner.Worker/Handlers/ScriptHandlerHelpers.cs#L9-L17
|
||||
// Reference: https://github.com/actions/runner/blob/8109c962f09d9acc473d92c595ff43afceddb347/src/Runner.Worker/Handlers/ScriptHandlerHelpers.cs#L9-L17
|
||||
switch s.Shell {
|
||||
case "", "bash":
|
||||
shellCommand = "bash --noprofile --norc -e -o pipefail {0}"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue