Possible to get Railway variables in Github Action?

2 years ago

I have postgres next to my app service in Railway. Automated Github environments are enabled in Railway.

I wanted to run Drizzle's database management tool, Drizzle Studio on each Railway deploy. To do that, I wanted to use a Github Action, so that when I push to my branch it'll run the studio.

However I run into the problem that I don't know how to dynamically insert the DATABASE_URL service variable that Railway generates. I could hardcode it for my main or staging environments, but was wondering if there's a way to dynamically insert these?

If not, any suggestions on how I could run a database admin tool that allows me to edit the postgres db spun up for each new Railway environment?

Thx

Closed

18 Replies

2 years ago

1fb7b057-4030-4839-a1f8-68638ed52a4e


2 years ago

perhaps the railway variables would help? -


2 years ago

Hey Brody, thanks for the quick response. What about a different question -- do you have any tips for how to most easily admin a postgres database spun up in a new Railway environment? Just using pgadmin locally? Or deploying that as a template? Or is there another route that's obvious (but I'm missing)?


2 years ago

i really like using dbgate locally so thats what id recommend - the dbgate template


2 years ago

Oh cool. Had not heard of it. Will check it out.


2 years ago

Followup question here. Would one typically admin a database by connecting to a production database from a local admin tool, or would you host a template of dbgate/pgadmin in every Railway environment next to the database? Is that a particularly resource intensive thing to run, or negligible?


2 years ago

hard question to answer because i dont know your needs, for example you may not want to expose the database publicly so then you'd want deploy dbgate into your project, but if you dont care about having your database exposed publicly then using dbgate (or similar software) locally is an option, additionally, you should be able to have dbgate sleep so that it doesnt use any cpu and mem when you arent using it


2 years ago

That's very helpful. If I enable sleeping such a service in Railway, can I still use private networking to have the admin tool connect to the database? Or would it have to use the PUBLIC_DATABASE_URL?


2 years ago

yep since dbgate does the database connection from its backend so you will be able to use the private database url


2 years ago

Ah that's nice. I just can't use private networking to connect to the admin service then?


2 years ago

Not that that would be necessary.


2 years ago

you could with tailscale but i think thats overkill


2 years ago

Yeah no need.


2 years ago

Will give these options a try. Thanks a bunch.


2 years ago

no problem!


2 years ago

dbgate is perfect for my needs. Will rock that for now.


2 years ago

awsome!


2 years ago

Should I close this post? I already tagged as 'solved'.


Welcome!

Sign in to your Railway account to join the conversation.

Loading...