mirror of
				https://gitea.com/Lydanne/buildx.git
				synced 2025-11-04 10:03:42 +08:00 
			
		
		
		
	Merge pull request #3001 from crazy-max/fix-gha-cache-v2
cache: enable gha cache backend if cache service v2 detected
This commit is contained in:
		@@ -207,6 +207,7 @@ func addGithubToken(ci *controllerapi.CacheOptionsEntry) {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	version, ok := ci.Attrs["version"]
 | 
						version, ok := ci.Attrs["version"]
 | 
				
			||||||
	if !ok {
 | 
						if !ok {
 | 
				
			||||||
 | 
							// https://github.com/actions/toolkit/blob/2b08dc18f261b9fdd978b70279b85cbef81af8bc/packages/cache/src/internal/config.ts#L19
 | 
				
			||||||
		if v, ok := os.LookupEnv("ACTIONS_CACHE_SERVICE_V2"); ok {
 | 
							if v, ok := os.LookupEnv("ACTIONS_CACHE_SERVICE_V2"); ok {
 | 
				
			||||||
			if b, err := strconv.ParseBool(v); err == nil && b {
 | 
								if b, err := strconv.ParseBool(v); err == nil && b {
 | 
				
			||||||
				version = "2"
 | 
									version = "2"
 | 
				
			||||||
@@ -218,15 +219,18 @@ func addGithubToken(ci *controllerapi.CacheOptionsEntry) {
 | 
				
			|||||||
			ci.Attrs["token"] = v
 | 
								ci.Attrs["token"] = v
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if _, ok := ci.Attrs["url"]; !ok {
 | 
						if _, ok := ci.Attrs["url_v2"]; !ok && version == "2" {
 | 
				
			||||||
		if version == "2" {
 | 
							// https://github.com/actions/toolkit/blob/2b08dc18f261b9fdd978b70279b85cbef81af8bc/packages/cache/src/internal/config.ts#L34-L35
 | 
				
			||||||
		if v, ok := os.LookupEnv("ACTIONS_RESULTS_URL"); ok {
 | 
							if v, ok := os.LookupEnv("ACTIONS_RESULTS_URL"); ok {
 | 
				
			||||||
			ci.Attrs["url_v2"] = v
 | 
								ci.Attrs["url_v2"] = v
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		} else {
 | 
						}
 | 
				
			||||||
 | 
						if _, ok := ci.Attrs["url"]; !ok {
 | 
				
			||||||
 | 
							// https://github.com/actions/toolkit/blob/2b08dc18f261b9fdd978b70279b85cbef81af8bc/packages/cache/src/internal/config.ts#L28-L33
 | 
				
			||||||
		if v, ok := os.LookupEnv("ACTIONS_CACHE_URL"); ok {
 | 
							if v, ok := os.LookupEnv("ACTIONS_CACHE_URL"); ok {
 | 
				
			||||||
			ci.Attrs["url"] = v
 | 
								ci.Attrs["url"] = v
 | 
				
			||||||
			}
 | 
							} else if v, ok := os.LookupEnv("ACTIONS_RESULTS_URL"); ok {
 | 
				
			||||||
 | 
								ci.Attrs["url"] = v
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -266,5 +270,5 @@ func isActive(pb *controllerapi.CacheOptionsEntry) bool {
 | 
				
			|||||||
	if pb.Type != "gha" {
 | 
						if pb.Type != "gha" {
 | 
				
			||||||
		return true
 | 
							return true
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return pb.Attrs["token"] != "" && pb.Attrs["url"] != ""
 | 
						return pb.Attrs["token"] != "" && (pb.Attrs["url"] != "" || pb.Attrs["url_v2"] != "")
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user