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

Function buildMaintenanceWorkflowYAML

pkg/workflow/maintenance_workflow_yaml.go:34–1006  ·  view source on GitHub ↗

buildMaintenanceWorkflowYAML generates the complete YAML content for the agentics-maintenance.yml workflow. It is called by GenerateMaintenanceWorkflow after the cron schedule and setup parameters have been resolved.

(
	ctx context.Context,
	opts buildMaintenanceWorkflowYAMLOptions,
)

Source from the content-addressed store, hash-verified

32// agentics-maintenance.yml workflow. It is called by GenerateMaintenanceWorkflow
33// after the cron schedule and setup parameters have been resolved.
34func buildMaintenanceWorkflowYAML(
35 ctx context.Context,
36 opts buildMaintenanceWorkflowYAMLOptions,
37) string {
38 cronSchedule := opts.cronSchedule
39 scheduleDesc := opts.scheduleDesc
40 minExpiresDays := opts.minExpiresDays
41 runsOnValue := opts.runsOnValue
42 actionMode := opts.actionMode
43 version := opts.version
44 actionTag := opts.actionTag
45 resolver := opts.resolver
46 configuredRunsOn := opts.configuredRunsOn
47 defaultBranch := opts.defaultBranch
48 disableLabelTrigger := opts.disableLabelTrigger
49 compileGitHubToken := opts.compileGitHubToken
50 createCompilePR := opts.createCompilePR
51 copilotOrgBilling := opts.copilotOrgBilling
52 maintenanceWorkflowYAMLLog.Printf("Building maintenance workflow YAML: actionMode=%s minExpiresDays=%d cronSchedule=%q defaultBranch=%q disableLabelTrigger=%v createCompilePR=%v copilotOrgBilling=%v", actionMode, minExpiresDays, cronSchedule, defaultBranch, disableLabelTrigger, createCompilePR, copilotOrgBilling)
53
54 var yaml strings.Builder
55
56 // Add workflow header with logo and instructions
57 customInstructions := `This file defines the generated agentic maintenance workflow for this repository.
58It runs scheduled cleanup for expiring safe outputs and supports manual maintenance operations.
59
60This workflow is generated automatically when workflows use expiring safe outputs
61or when repository maintenance features are enabled in .github/workflows/aw.json.
62
63To disable maintenance workflow generation, set in .github/workflows/aw.json:
64 {"maintenance": false}
65
66Agentic maintenance docs:
67 https://github.github.com/gh-aw/reference/ephemerals/#manual-maintenance-operations`
68
69 header := GenerateWorkflowHeader("", "pkg/workflow/maintenance_workflow.go", customInstructions)
70 yaml.WriteString(header)
71
72 yaml.WriteString(`name: Agentic Maintenance
73
74on:
75 schedule:
76 - cron: "` + cronSchedule + `" # ` + scheduleDesc + ` (based on minimum expires: ` + strconv.Itoa(minExpiresDays) + ` days)
77`)
78
79 // Add push trigger in dev mode so compile-workflows runs when workflow files change
80 if actionMode == ActionModeDev {
81 maintenanceWorkflowYAMLLog.Printf("Adding dev-mode push trigger for branch %q", defaultBranch)
82 yaml.WriteString(` push:
83 branches:
84 - ` + defaultBranch + `
85 paths:
86 - '.github/workflows/*.md'
87`)
88 }
89
90 // Add label-event trigger only when the label-triggered jobs are enabled
91 if !disableLabelTrigger {

Calls 15

GenerateWorkflowHeaderFunction · 0.85
RenderConditionFunction · 0.85
getActionPinFunction · 0.85
generateInstallCLIStepsFunction · 0.85
getCLICmdPrefixFunction · 0.85
FormatRunsOnFunction · 0.85