I am trying to publish a container image to ghcr.io. Below is my Publish functtion. It is very basic. Also below you can see where I export the GHCR_TOKEN environment variable on my workstation and call the publish function which gives secret env var not found: "GHC..." I am hoping this is something easy that I am not seeing. My best guess is it might have something to with the fact that I am running the Dagger Engine in a remote K8s cluster and I connect to it via _EXPERIMENTAL_DAGGER_RUNNER_HOST but I am not sure how to debug this?
func (m *SreAiAgent) Publish(
ctx context.Context,
// Registry address
registry string,
// Registry username
username string,
// Registry password
password *dagger.Secret,
) (string, error) {
return m.BuildEnv().
WithRegistryAuth(registry, username, password).
Publish(ctx, fmt.Sprintf("%s/%s/sre-ai-agent:dev", registry, username))
}
# Run this on my workstation
export GHCR_TOKEN=ghp_abc123mytoken
dagger -c 'publish ghcr.io tonygilkerson env://GHCR_TOKEN'
╰─✘ .withRegistryAuth(
┆ address: "ghcr.io"
┆ username: "tonygilkerson"
┆ secret: secret(uri: "env://GHCR_TOKEN"): Secret!
): Container! 0.0s ERROR
! secret env var not found: "GHC..."