mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-05-29 08:57:44 +08:00
allow exporting to github cache backend
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
parent
319b6503a5
commit
3fef64f584
@ -2,6 +2,7 @@ package build
|
||||
|
||||
import (
|
||||
"encoding/csv"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/moby/buildkit/client"
|
||||
@ -45,6 +46,9 @@ func ParseCacheEntry(in []string) ([]client.CacheOptionsEntry, error) {
|
||||
if im.Type == "" {
|
||||
return nil, errors.Errorf("type required form> %q", in)
|
||||
}
|
||||
if !addGithubToken(&im) {
|
||||
continue
|
||||
}
|
||||
imports = append(imports, im)
|
||||
}
|
||||
return imports, nil
|
||||
@ -58,3 +62,20 @@ func isRefOnlyFormat(in []string) bool {
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func addGithubToken(ci *client.CacheOptionsEntry) bool {
|
||||
if ci.Type != "gha" {
|
||||
return true
|
||||
}
|
||||
if _, ok := ci.Attrs["token"]; !ok {
|
||||
if v, ok := os.LookupEnv("ACTIONS_RUNTIME_TOKEN"); ok {
|
||||
ci.Attrs["token"] = v
|
||||
}
|
||||
}
|
||||
if _, ok := ci.Attrs["url"]; !ok {
|
||||
if v, ok := os.LookupEnv("ACTIONS_CACHE_URL"); ok {
|
||||
ci.Attrs["url"] = v
|
||||
}
|
||||
}
|
||||
return ci.Attrs["token"] != "" && ci.Attrs["url"] != ""
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user