@@ -206,43 +206,6 @@ func (evt *Event) Inputs() []WorkflowDispatchInput {
206206 return evt .inputs
207207}
208208
209- func parseWorkflowDispatchInputs (inputs map [string ]interface {}) ([]WorkflowDispatchInput , error ) {
210- var results []WorkflowDispatchInput
211- for name , input := range inputs {
212- inputMap , ok := input .(map [string ]interface {})
213- if ! ok {
214- return nil , fmt .Errorf ("invalid input: %v" , input )
215- }
216- input := WorkflowDispatchInput {
217- Name : name ,
218- }
219- if desc , ok := inputMap ["description" ].(string ); ok {
220- input .Description = desc
221- }
222- if required , ok := inputMap ["required" ].(bool ); ok {
223- input .Required = required
224- }
225- if defaultVal , ok := inputMap ["default" ].(string ); ok {
226- input .Default = defaultVal
227- }
228- if inputType , ok := inputMap ["type" ].(string ); ok {
229- input .Type = inputType
230- }
231- if options , ok := inputMap ["options" ].([]string ); ok {
232- input .Options = options
233- } else if options , ok := inputMap ["options" ].([]interface {}); ok {
234- for _ , option := range options {
235- if opt , ok := option .(string ); ok {
236- input .Options = append (input .Options , opt )
237- }
238- }
239- }
240-
241- results = append (results , input )
242- }
243- return results , nil
244- }
245-
246209// Helper to convert actionlint errors
247210func acErrToError (acErrs []* actionlint.Error ) []error {
248211 errs := make ([]error , len (acErrs ))
@@ -339,6 +302,16 @@ func GetEventsFromContent(content []byte) ([]*Event, error) {
339302 return events , nil
340303}
341304
305+ func ValidateWorkflow (content []byte ) error {
306+ _ , errs := actionlint .Parse (content )
307+ err := make ([]error , len (errs ))
308+ for _ , e := range errs {
309+ err = append (err , fmt .Errorf ("%d:%d: %s" , e .Line , e .Column , e .Message ))
310+ }
311+ return errors .Join (err ... )
312+
313+ }
314+
342315// parseMappingNode parse a mapping node and preserve order.
343316func parseMappingNode [T any ](node * yaml.Node ) ([]string , []T , error ) {
344317 if node .Kind != yaml .MappingNode {
0 commit comments