diff --git a/.github/actions/go-cache/action.sh b/.github/actions/go-cache/action.sh index f49d5bb779..8d8c1263a5 100755 --- a/.github/actions/go-cache/action.sh +++ b/.github/actions/go-cache/action.sh @@ -49,6 +49,7 @@ fi echo "Fetched cigocacher token successfully" echo "::add-mask::${CIGOCACHER_TOKEN}" +echo "CIGOCACHER_TOKEN=${CIGOCACHER_TOKEN}" >> "${GITHUB_ENV}" -echo "GOCACHEPROG=${BIN_PATH} --cache-dir ${CACHE_DIR} --cigocached-url ${URL} --cigocached-host ${HOST} --token ${CIGOCACHER_TOKEN}" >> "${GITHUB_ENV}" +echo "GOCACHEPROG=${BIN_PATH} --cache-dir ${CACHE_DIR} --cigocached-url ${URL} --cigocached-host ${HOST}" >> "${GITHUB_ENV}" echo "success=true" >> "${GITHUB_OUTPUT}" diff --git a/cmd/cigocacher/cigocacher.go b/cmd/cigocacher/cigocacher.go index b308afd06d..9745977a97 100644 --- a/cmd/cigocacher/cigocacher.go +++ b/cmd/cigocacher/cigocacher.go @@ -40,13 +40,17 @@ func main() { version = flag.Bool("version", false, "print version and exit") auth = flag.Bool("auth", false, "auth with cigocached and exit, printing the access token as output") stats = flag.Bool("stats", false, "fetch and print cigocached stats and exit") - token = flag.String("token", "", "the cigocached access token to use, as created using --auth") + token = flag.String("token", "", "the cigocached access token to use, as created using --auth; defaults to CIGOCACHER_TOKEN env var if set") srvURL = flag.String("cigocached-url", "", "optional cigocached URL (scheme, host, and port). Empty means to not use one.") srvHostDial = flag.String("cigocached-host", "", "optional cigocached host to dial instead of the host in the provided --cigocached-url. Useful for public TLS certs on private addresses.") dir = flag.String("cache-dir", "", "cache directory; empty means automatic") verbose = flag.Bool("verbose", false, "enable verbose logging") ) flag.Parse() + // Default --token _after_ parsing flags so we don't print it in --help output. + if *token == "" { + *token = os.Getenv("CIGOCACHER_TOKEN") + } if *version { info, ok := debug.ReadBuildInfo()