RunUpdateWorkflows updates workflows from their source repositories. Each workflow is compiled immediately after update.
(ctx context.Context, opts UpdateWorkflowsOptions)
| 196 | // RunUpdateWorkflows updates workflows from their source repositories. |
| 197 | // Each workflow is compiled immediately after update. |
| 198 | func RunUpdateWorkflows(ctx context.Context, opts UpdateWorkflowsOptions) error { |
| 199 | updateLog.Printf("Starting update process: workflows=%v, allowMajor=%v, force=%v, noMerge=%v, disableReleaseBump=%v, noCompile=%v, noRedirect=%v, coolDown=%v", opts.WorkflowNames, opts.AllowMajor, opts.Force, opts.NoMerge, opts.DisableReleaseBump, opts.NoCompile, opts.NoRedirect, opts.CoolDown) |
| 200 | |
| 201 | var firstErr error |
| 202 | |
| 203 | if err := UpdateWorkflows(ctx, opts); err != nil { |
| 204 | firstErr = fmt.Errorf("workflow update failed: %w", err) |
| 205 | } |
| 206 | |
| 207 | // Update GitHub Actions versions in actions-lock.json. |
| 208 | // By default all actions are updated to the latest major version. |
| 209 | // Pass --no-release-bump to revert to only forcing updates for core (actions/*) actions. |
| 210 | updateLog.Printf("Updating GitHub Actions versions in actions-lock.json: allowMajor=%v, disableReleaseBump=%v", opts.AllowMajor, opts.DisableReleaseBump) |
| 211 | if err := UpdateActions(ctx, opts.AllowMajor, opts.Verbose, opts.DisableReleaseBump, opts.CoolDown); err != nil { |
| 212 | // Non-fatal: warn but don't fail the update |
| 213 | fmt.Fprintln(os.Stderr, console.FormatWarningMessage(fmt.Sprintf("Warning: Failed to update actions-lock.json: %v", err))) |
| 214 | } |
| 215 | |
| 216 | // Update action references in user-provided steps within workflow .md files. |
| 217 | // By default all org/repo@version references are updated to the latest major version. |
| 218 | updateLog.Print("Updating action references in workflow .md files") |
| 219 | if err := UpdateActionsInWorkflowFiles(ctx, opts.WorkflowsDir, opts.EngineOverride, opts.Verbose, opts.DisableReleaseBump, opts.NoCompile, opts.CoolDown); err != nil { |
| 220 | // Non-fatal: warn but don't fail the update |
| 221 | fmt.Fprintln(os.Stderr, console.FormatWarningMessage(fmt.Sprintf("Warning: Failed to update action references in workflow files: %v", err))) |
| 222 | } |
| 223 | |
| 224 | // Resolve and store SHA-256 digest pins for container images referenced in lock files. |
| 225 | // This runs after compilation (via UpdateActionsInWorkflowFiles) so that the lock files |
| 226 | // already reflect the current AWF version; stale pins from superseded versions are pruned |
| 227 | // and new versions are resolved in a single pass. |
| 228 | updateLog.Print("Updating container image digest pins") |
| 229 | newContainerPins, err := UpdateContainerPins(ctx, opts.WorkflowsDir, opts.Verbose) |
| 230 | if err != nil { |
| 231 | // Non-fatal: Docker may not be available in all environments. |
| 232 | fmt.Fprintln(os.Stderr, console.FormatWarningMessage(fmt.Sprintf("Warning: Failed to update container pins: %v", err))) |
| 233 | } |
| 234 | |
| 235 | // Recompile all workflows when new container pins were added so that the |
| 236 | // lock files embed the digest-pinned image references (image:tag@sha256:…). |
| 237 | if newContainerPins && !opts.NoCompile { |
| 238 | updateLog.Print("Recompiling workflows to embed new container digest pins") |
| 239 | fmt.Fprintln(os.Stderr, console.FormatInfoMessage("Recompiling workflows to embed container digest pins...")) |
| 240 | recompileErr := recompileAllWorkflows(ctx, opts.WorkflowsDir, opts.EngineOverride, opts.Verbose) |
| 241 | if recompileErr != nil { |
| 242 | fmt.Fprintln(os.Stderr, console.FormatWarningMessage(fmt.Sprintf("Warning: Failed to recompile workflows after container pin update: %v", recompileErr))) |
| 243 | } |
| 244 | } |
| 245 | |
| 246 | updateLog.Printf("Update process complete: had_error=%v", firstErr != nil) |
| 247 | return firstErr |
| 248 | } |
| 249 | |
| 250 | // recompileAllWorkflows recompiles all .md workflow files in the given directory. |
| 251 | // This is used after container pin updates to embed digest-pinned image references |