NewUpdateCommand creates the update command
(validateEngine func(string) error)
| 22 | |
| 23 | // NewUpdateCommand creates the update command |
| 24 | func NewUpdateCommand(validateEngine func(string) error) *cobra.Command { |
| 25 | cmd := &cobra.Command{ |
| 26 | Use: "update [workflow]...", |
| 27 | Short: "Update agentic workflows from their source repositories", |
| 28 | Long: `Update one or more agentic workflows from their source repositories. |
| 29 | |
| 30 | The update command fetches the latest version of each workflow from its source |
| 31 | repository, merges upstream changes with any local modifications, and recompiles. |
| 32 | |
| 33 | If no workflow names are specified, all workflows with a 'source' field are updated. |
| 34 | |
| 35 | By default, the update performs a 3-way merge to preserve your local changes. |
| 36 | Use --no-merge to override local changes with the upstream version. |
| 37 | |
| 38 | For workflow updates, it fetches the latest version based on the current ref: |
| 39 | - If the ref is a tag, it updates to the latest release (use --major for major version updates) |
| 40 | - If the ref is a branch, it fetches the latest commit from that branch |
| 41 | - If the ref is a commit SHA, it fetches the latest commit from the default branch |
| 42 | |
| 43 | For extension updates, action updates, agent files, and codemods, use 'gh aw upgrade'. |
| 44 | |
| 45 | Note: In GitHub Enterprise repos, shorthand source specs resolve on your enterprise host by default. |
| 46 | For github/*, githubnext/*, and microsoft/* sources, shorthand resolves on github.com. |
| 47 | Use full https://github.com/... source URLs for other public github.com workflows. |
| 48 | |
| 49 | ` + WorkflowIDExplanation, |
| 50 | Example: ` ` + string(constants.CLIExtensionPrefix) + ` update # Update all workflows from source |
| 51 | ` + string(constants.CLIExtensionPrefix) + ` update repo-assist # Update a specific workflow |
| 52 | ` + string(constants.CLIExtensionPrefix) + ` update repo-assist.md # Same (alternative format) |
| 53 | ` + string(constants.CLIExtensionPrefix) + ` update --org my-org # Preview workflow updates across an organization |
| 54 | ` + string(constants.CLIExtensionPrefix) + ` update --org my-org --repos '*-service' # Limit org mode to matching repositories |
| 55 | ` + string(constants.CLIExtensionPrefix) + ` update --org my-org --create-issue # Open issues in repos with pending updates |
| 56 | ` + string(constants.CLIExtensionPrefix) + ` update --org my-org --create-issue --yes # Auto-accept per-repo confirmations (required in CI) |
| 57 | ` + string(constants.CLIExtensionPrefix) + ` update --org my-org --create-pull-request --yes # Auto-accept per-repo confirmations for PR creation (required in CI) |
| 58 | ` + string(constants.CLIExtensionPrefix) + ` update --no-merge # Override local changes with upstream |
| 59 | ` + string(constants.CLIExtensionPrefix) + ` update repo-assist --major # Allow major version updates |
| 60 | ` + string(constants.CLIExtensionPrefix) + ` update --force # Force update even if no changes |
| 61 | ` + string(constants.CLIExtensionPrefix) + ` update --no-release-bump # Update without force-bumping all action versions |
| 62 | ` + string(constants.CLIExtensionPrefix) + ` update --no-compile # Update without regenerating lock files |
| 63 | ` + string(constants.CLIExtensionPrefix) + ` update --no-redirect # Refuse workflows that use redirect frontmatter |
| 64 | ` + string(constants.CLIExtensionPrefix) + ` update --dir custom/workflows # Update workflows in custom directory |
| 65 | ` + string(constants.CLIExtensionPrefix) + ` update --repo owner/repo # Update workflows in another repository |
| 66 | ` + string(constants.CLIExtensionPrefix) + ` update --create-pull-request # Update and open a pull request |
| 67 | ` + string(constants.CLIExtensionPrefix) + ` update --cool-down 0 # Disable cooldown and apply all pending releases immediately |
| 68 | ` + string(constants.CLIExtensionPrefix) + ` update --cool-down 3d # Apply a custom 3-day cooldown period`, |
| 69 | RunE: func(cmd *cobra.Command, args []string) error { |
| 70 | majorFlag, _ := cmd.Flags().GetBool("major") |
| 71 | forceFlag, _ := cmd.Flags().GetBool("force") |
| 72 | engineOverride, _ := cmd.Flags().GetString("engine") |
| 73 | verbose, _ := cmd.Flags().GetBool("verbose") |
| 74 | workflowDir, _ := cmd.Flags().GetString("dir") |
| 75 | noStopAfter, _ := cmd.Flags().GetBool("no-stop-after") |
| 76 | stopAfter, _ := cmd.Flags().GetString("stop-after") |
| 77 | noMergeFlag, _ := cmd.Flags().GetBool("no-merge") |
| 78 | disableReleaseBump, _ := cmd.Flags().GetBool("no-release-bump") |
| 79 | disableReleaseBumpLegacy, _ := cmd.Flags().GetBool("disable-release-bump") |
| 80 | disableReleaseBump = disableReleaseBump || disableReleaseBumpLegacy |
| 81 | noCompile, _ := cmd.Flags().GetBool("no-compile") |