#Hey guys ๐ How can I pass a secretEnv
1 messages ยท Page 1 of 1 (latest)
๐ this works amigo
{
core {
image(ref: "alpine") {
exec(
input: {args: ["printenv", "VERCEL_TOKEN"], secretEnv: {name: "VERCEL_TOKEN", id: "2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae"}}
) {
stderr
stdout
}
}
}
}```
you need to call the addSecret query before that to get the correct secretId
Thanks
already done ๐
take into account that ${VERCEL_TOKEN} is a shell expansion, so you need to use a shell to call the vercel CLI on order to send the token as a CLI argument
the vercel CLI doesn't pick up a token env variable automatically?
you mean with those args for instance 'sh', '-c' ?
maybe I'm missing something but apparently not. However you can set env with vercel env add...
yes
that's for a different thing I think
vercel doesnโt seem thrilled about being wrapped
do they have a typescript client library maybe?
You could create an auth.json but it doesnโt seem recommended (and format is not documented) https://vercel.com/docs/project-configuration#global-configuration/auth-json
they have a rest api : https://vercel.com/docs/rest-api
I wanted to create an extension with it
by using axios
I think your options are:
-
Execute a shell script and pass token env to that, the `${TOKEN}โ will work as @modern sparrow explained
-
use a client library instead
-
find a way to configure the CLI that we havenโt seen
I would start with 1) since youโre not far
core {
image(ref: "index.docker.io/dockette/vercel") {
exec(
input: {
args: [
"sh"
"-c"
"vercel"
"--name"
"dagger_io"
"deploy"
"./out"
"-t"
"VERCEL_TOKEN"
"--scope"
"dagger"
"-c"
]
mounts: [{ fs: $sourceAfterBuild, path: "/src" }]
workdir: "/src"
secretEnv: { name: "VERCEL_TOKEN", id: $tokenSecretId }
}
) {
stderr
stdout
}
}
}
this doesn't work
VERCEL_TOKEN still needs the ${} thingy
๐ค
np!
He doesnโt understand (yet)
ahahah
with ${} I've got ReferenceError: VERCEL_TOKEN is not defined
I'll come back later when kids will sleep. Thanks guys for your help ๐
this works
{core {
image(ref: "index.docker.io/dockette/vercel") {
exec(
input: {
args: [
"sh"
"-c",
"vercel --token ${VERCEL_TOKEN}"
]
secretEnv: { name: "VERCEL_TOKEN", id: "2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae" }
}
) {
stderr
stdout
}
}
}
}```
not for me ๐ค
So the solution is to use the following syntax $VERCEL_TOKEN. The ${} seems to be interpretated by JS. Thanks @floral forge ๐