How to retrieve env vars from railway?
afinvoice
HOBBYOP

2 years ago

I need to use them in github action and I don't want to have them as a secret in github as well as in railway.

10 Replies

afinvoice
HOBBYOP

2 years ago

N/A


2 years ago

do you already use the railway cli in this action?


afinvoice
HOBBYOP

2 years ago

It just occured to me I could use the CLI for this.


2 years ago

yep the cli has a --kv flag for the variables command and you could definitely use that in some way


afinvoice
HOBBYOP

2 years ago

Have u used it?


2 years ago

only locally, it prints all the services variables is key value format -

foo=bar
baz=qux

afinvoice
HOBBYOP

2 years ago

Nice, thanks for the help!


2 years ago

let me know what you end up doing with this, I'd love to hear


afinvoice
HOBBYOP

2 years ago

I've been scratching my head for a while trying to figure out why when running this command in my GitHub Action returns weird value for DATABASE_URL.

railway variables --service ${{ inputs.railway-service-id }} --kv

...
DATABASE_URL=***postgres.railway.internal:5432/railway
...

Do you happen to know why?


afinvoice
HOBBYOP

2 years ago

When running this command RAILWAY_TOKEN=xxx railway variables --service xxx --kv on my local machine it gives a correct value of DATABASE_URL.


Loading...