MCPcopy Create free account
hub / github.com/github/gh-aw / excludeExistingSourcedWorkflows

Function excludeExistingSourcedWorkflows

pkg/cli/deploy_command.go:294–324  ·  view source on GitHub ↗
(workflows []string, addOpts AddOptions)

Source from the content-addressed store, hash-verified

292}
293
294func excludeExistingSourcedWorkflows(workflows []string, addOpts AddOptions) ([]string, []string, error) {
295 workflowsDir := addOpts.WorkflowDir
296 if workflowsDir == "" {
297 workflowsDir = getWorkflowsDir()
298 }
299
300 workflowsToAdd := make([]string, 0, len(workflows))
301 skippedWorkflows := make([]string, 0)
302
303 for _, workflowSpec := range workflows {
304 workflowName := normalizeWorkflowID(workflowSpec)
305 if addOpts.Name != "" && len(workflows) == 1 {
306 workflowName = normalizeWorkflowID(addOpts.Name)
307 }
308
309 existingPath := filepath.Join(workflowsDir, workflowName+".md")
310 hasSource, err := existingWorkflowHasSource(existingPath)
311 if err != nil {
312 return nil, nil, err
313 }
314
315 if hasSource {
316 skippedWorkflows = append(skippedWorkflows, workflowName)
317 continue
318 }
319
320 workflowsToAdd = append(workflowsToAdd, workflowSpec)
321 }
322
323 return workflowsToAdd, skippedWorkflows, nil
324}
325
326func existingWorkflowHasSource(path string) (bool, error) {
327 content, err := os.ReadFile(path)

Calls 3

getWorkflowsDirFunction · 0.85
normalizeWorkflowIDFunction · 0.85