Possible to get Railway variables in Github Action?
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?
ThxDrizzle ORM - Meet Drizzle Studio
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
16 Replies
Project ID:
1fb7b057-4030-4839-a1f8-68638ed52a4e
1fb7b057-4030-4839-a1f8-68638ed52a4e
Solution
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)?
i really like using dbgate locally so thats what id recommend - the dbgate template
Oh cool. Had not heard of it. Will check it out.
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?
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
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
?yep since dbgate does the database connection from its backend so you will be able to use the private database url
Ah that's nice. I just can't use private networking to connect to the admin service then?
Not that that would be necessary.
you could with tailscale but i think thats overkill
Yeah no need.
Will give these options a try. Thanks a bunch.
no problem!
dbgate is perfect for my needs. Will rock that for now.
awsome!
Should I close this post? I already tagged as 'solved'.