Detect workflow event type
This commit is contained in:
parent
32c1ec97e6
commit
96065fe807
2 changed files with 15 additions and 12 deletions
|
@ -55,18 +55,9 @@ func (runner *runnerImpl) setupWorkflows() error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
defer workflowReader.Close()
|
||||
|
||||
runner.workflowConfig, err = parser.Parse(workflowReader)
|
||||
/*
|
||||
if err != nil {
|
||||
parserError := err.(*parser.ParserError)
|
||||
for _, e := range parserError.Errors {
|
||||
fmt.Fprintln(os.Stderr, e)
|
||||
}
|
||||
}
|
||||
*/
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
18
cmd/root.go
18
cmd/root.go
|
@ -50,9 +50,7 @@ func setupLogging(cmd *cobra.Command, args []string) {
|
|||
|
||||
func newRunCommand(runnerConfig *actions.RunnerConfig) func(*cobra.Command, []string) error {
|
||||
return func(cmd *cobra.Command, args []string) error {
|
||||
if len(args) == 0 {
|
||||
runnerConfig.EventName = "push"
|
||||
} else {
|
||||
if len(args) > 0 {
|
||||
runnerConfig.EventName = args[0]
|
||||
}
|
||||
|
||||
|
@ -77,6 +75,20 @@ func parseAndRun(cmd *cobra.Command, runnerConfig *actions.RunnerConfig) error {
|
|||
}
|
||||
defer runner.Close()
|
||||
|
||||
// set default event type if we only have a single workflow in the file.
|
||||
// this way user dont have to specify the event.
|
||||
if runnerConfig.EventName == "" {
|
||||
if events := runner.ListEvents(); len(events) == 1 {
|
||||
log.Debugf("Using detected workflow event: %s", events[0])
|
||||
runnerConfig.EventName = events[0]
|
||||
}
|
||||
}
|
||||
|
||||
// fall back to default event name if we could not detect one.
|
||||
if runnerConfig.EventName == "" {
|
||||
runnerConfig.EventName = "push"
|
||||
}
|
||||
|
||||
// check if we should just print the graph
|
||||
list, err := cmd.Flags().GetBool("list")
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in a new issue