@@ -37,20 +37,22 @@ Examples:
3737 ` + constants .CLIExtensionPrefix + ` update ci-doctor # Check gh-aw updates and update specific workflow
3838 ` + constants .CLIExtensionPrefix + ` update ci-doctor --major # Allow major version updates
3939 ` + constants .CLIExtensionPrefix + ` update --pr # Create PR with changes
40- ` + constants .CLIExtensionPrefix + ` update --force # Force update even if no changes` ,
40+ ` + constants .CLIExtensionPrefix + ` update --force # Force update even if no changes
41+ ` + constants .CLIExtensionPrefix + ` update --dir custom/workflows # Update workflows in custom directory` ,
4142 Run : func (cmd * cobra.Command , args []string ) {
4243 majorFlag , _ := cmd .Flags ().GetBool ("major" )
4344 forceFlag , _ := cmd .Flags ().GetBool ("force" )
4445 engineOverride , _ := cmd .Flags ().GetString ("engine" )
4546 verbose , _ := cmd .Flags ().GetBool ("verbose" )
4647 prFlag , _ := cmd .Flags ().GetBool ("pr" )
48+ workflowDir , _ := cmd .Flags ().GetString ("dir" )
4749
4850 if err := validateEngine (engineOverride ); err != nil {
4951 fmt .Fprintln (os .Stderr , console .FormatErrorMessage (err .Error ()))
5052 os .Exit (1 )
5153 }
5254
53- if err := UpdateWorkflowsWithExtensionCheck (args , majorFlag , forceFlag , verbose , engineOverride , prFlag ); err != nil {
55+ if err := UpdateWorkflowsWithExtensionCheck (args , majorFlag , forceFlag , verbose , engineOverride , prFlag , workflowDir ); err != nil {
5456 fmt .Fprintln (os .Stderr , console .FormatErrorMessage (err .Error ()))
5557 os .Exit (1 )
5658 }
@@ -61,6 +63,7 @@ Examples:
6163 cmd .Flags ().Bool ("force" , false , "Force update even if no changes detected" )
6264 cmd .Flags ().StringP ("engine" , "e" , "" , "Override AI engine (claude, codex, copilot, custom)" )
6365 cmd .Flags ().Bool ("pr" , false , "Create a pull request with the workflow changes" )
66+ cmd .Flags ().String ("dir" , "" , "Relative directory containing workflows (default: .github/workflows)" )
6467
6568 return cmd
6669}
@@ -107,16 +110,20 @@ func checkExtensionUpdate(verbose bool) error {
107110}
108111
109112// runCompileWorkflows runs the compile command to recompile all workflows
110- func runCompileWorkflows (verbose bool , engineOverride string ) error {
113+ func runCompileWorkflows (verbose bool , engineOverride string , workflowsDir string ) error {
111114 if verbose {
112115 fmt .Fprintln (os .Stderr , console .FormatVerboseMessage ("Compiling workflows..." ))
113116 }
114117
115118 // Create a compiler instance similar to how compile command does it
116119 compiler := workflow .NewCompiler (verbose , engineOverride , GetVersion ())
117120
121+ // Use provided workflows directory or default
122+ if workflowsDir == "" {
123+ workflowsDir = getWorkflowsDir ()
124+ }
125+
118126 // Compile all workflows in the workflows directory
119- workflowsDir := getWorkflowsDir ()
120127 _ , err := compileAllWorkflowFiles (compiler , workflowsDir , verbose )
121128 if err != nil {
122129 return fmt .Errorf ("failed to compile workflows: %w" , err )
@@ -133,19 +140,19 @@ func runCompileWorkflows(verbose bool, engineOverride string) error {
133140// 2. Update workflows from source repositories
134141// 3. Compile all workflows
135142// 4. Optionally create a PR
136- func UpdateWorkflowsWithExtensionCheck (workflowNames []string , allowMajor , force , verbose bool , engineOverride string , createPR bool ) error {
143+ func UpdateWorkflowsWithExtensionCheck (workflowNames []string , allowMajor , force , verbose bool , engineOverride string , createPR bool , workflowsDir string ) error {
137144 // Step 1: Check for gh-aw extension updates
138145 if err := checkExtensionUpdate (verbose ); err != nil {
139146 return fmt .Errorf ("extension update check failed: %w" , err )
140147 }
141148
142149 // Step 2: Update workflows from source repositories
143- if err := UpdateWorkflows (workflowNames , allowMajor , force , verbose , engineOverride ); err != nil {
150+ if err := UpdateWorkflows (workflowNames , allowMajor , force , verbose , engineOverride , workflowsDir ); err != nil {
144151 return fmt .Errorf ("workflow update failed: %w" , err )
145152 }
146153
147154 // Step 3: Compile all workflows
148- if err := runCompileWorkflows (verbose , engineOverride ); err != nil {
155+ if err := runCompileWorkflows (verbose , engineOverride , workflowsDir ); err != nil {
149156 return fmt .Errorf ("compile failed: %w" , err )
150157 }
151158
@@ -243,8 +250,11 @@ func createUpdatePR(verbose bool) error {
243250}
244251
245252// UpdateWorkflows updates workflows from their source repositories
246- func UpdateWorkflows (workflowNames []string , allowMajor , force , verbose bool , engineOverride string ) error {
247- workflowsDir := getWorkflowsDir ()
253+ func UpdateWorkflows (workflowNames []string , allowMajor , force , verbose bool , engineOverride string , workflowsDir string ) error {
254+ // Use provided workflows directory or default
255+ if workflowsDir == "" {
256+ workflowsDir = getWorkflowsDir ()
257+ }
248258
249259 // Find all workflows with source field
250260 workflows , err := findWorkflowsWithSource (workflowsDir , workflowNames , verbose )
0 commit comments