R
Railway6d ago
Budi

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? Thx
Drizzle ORM - Meet Drizzle Studio
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
Solution:
perhaps the railway variables would help? - https://docs.railway.app/reference/cli-api#variables
Jump to solution
16 Replies
Percy
Percy6d ago
Project ID: 1fb7b057-4030-4839-a1f8-68638ed52a4e
Budi
Budi6d ago
1fb7b057-4030-4839-a1f8-68638ed52a4e
Solution
Brody
Brody6d ago
perhaps the railway variables would help? - https://docs.railway.app/reference/cli-api#variables
Budi
Budi6d 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)?
Brody
Brody6d ago
i really like using dbgate locally so thats what id recommend - the dbgate template
Budi
Budi6d ago
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?
Brody
Brody6d 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
Budi
Budi6d 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?
Brody
Brody6d ago
yep since dbgate does the database connection from its backend so you will be able to use the private database url
Budi
Budi6d ago
Ah that's nice. I just can't use private networking to connect to the admin service then? Not that that would be necessary.
Brody
Brody6d ago
you could with tailscale but i think thats overkill
Budi
Budi6d ago
Yeah no need. Will give these options a try. Thanks a bunch.
Brody
Brody6d ago
no problem!
Budi
Budi6d ago
dbgate is perfect for my needs. Will rock that for now.
Brody
Brody6d ago
awsome!
Want results from more Discord servers?
Add your server