parseUploadArtifactConfig parses the upload-artifact key from the safe-outputs map.
(outputMap map[string]any)
| 51 | |
| 52 | // parseUploadArtifactConfig parses the upload-artifact key from the safe-outputs map. |
| 53 | func (c *Compiler) parseUploadArtifactConfig(outputMap map[string]any) *UploadArtifactConfig { |
| 54 | configData, exists := outputMap["upload-artifact"] |
| 55 | if !exists { |
| 56 | return nil |
| 57 | } |
| 58 | |
| 59 | // Explicit false disables upload-artifact (e.g. when passed via import-inputs). |
| 60 | if b, ok := configData.(bool); ok && !b { |
| 61 | publishArtifactsLog.Print("upload-artifact explicitly set to false, skipping") |
| 62 | return nil |
| 63 | } |
| 64 | |
| 65 | publishArtifactsLog.Print("Parsing upload-artifact configuration") |
| 66 | config := &UploadArtifactConfig{ |
| 67 | MaxUploads: defaultArtifactMaxUploads, |
| 68 | MaxSizeBytes: defaultArtifactMaxSizeBytes, |
| 69 | } |
| 70 | |
| 71 | configMap, ok := configData.(map[string]any) |
| 72 | if !ok { |
| 73 | // No config map (e.g. upload-artifact: true) – use defaults. |
| 74 | publishArtifactsLog.Print("upload-artifact enabled with default configuration") |
| 75 | return config |
| 76 | } |
| 77 | |
| 78 | // Parse max-uploads. |
| 79 | if maxUploads, exists := configMap["max-uploads"]; exists { |
| 80 | if v, ok := typeutil.ParseIntValue(maxUploads); ok && v > 0 { |
| 81 | config.MaxUploads = v |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | // Parse retention-days (templatable int). |
| 86 | if err := preprocessIntFieldAsString(configMap, "retention-days", publishArtifactsLog); err != nil { |
| 87 | publishArtifactsLog.Printf("Warning: %v", err) |
| 88 | } |
| 89 | if retDays, exists := configMap["retention-days"]; exists { |
| 90 | if s, ok := retDays.(string); ok && s != "" { |
| 91 | config.RetentionDays = &s |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | // Parse skip-archive (templatable bool). |
| 96 | if err := preprocessBoolFieldAsString(configMap, "skip-archive", publishArtifactsLog); err != nil { |
| 97 | publishArtifactsLog.Printf("Warning: %v", err) |
| 98 | } |
| 99 | if skipArchive, exists := configMap["skip-archive"]; exists { |
| 100 | if s, ok := skipArchive.(string); ok && s != "" { |
| 101 | config.SkipArchive = &s |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | // Parse max-size-bytes. |
| 106 | if maxBytes, exists := configMap["max-size-bytes"]; exists { |
| 107 | if v, ok := typeutil.ParseIntValue(maxBytes); ok && v > 0 { |
| 108 | config.MaxSizeBytes = int64(v) |
| 109 | } |
| 110 | } |