R
Railway3mo 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
Percy3mo ago
Project ID: 1fb7b057-4030-4839-a1f8-68638ed52a4e
Budi
BudiOP3mo ago
1fb7b057-4030-4839-a1f8-68638ed52a4e
Solution
Brody
Brody3mo ago
perhaps the railway variables would help? - https://docs.railway.app/reference/cli-api#variables
Budi
BudiOP3mo 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
Brody3mo ago
i really like using dbgate locally so thats what id recommend - the dbgate template
Budi
BudiOP3mo 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
Brody3mo 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
BudiOP3mo 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
Brody3mo ago
yep since dbgate does the database connection from its backend so you will be able to use the private database url
Budi
BudiOP3mo 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
Brody3mo ago
you could with tailscale but i think thats overkill
Budi
BudiOP3mo ago
Yeah no need. Will give these options a try. Thanks a bunch.
Brody
Brody3mo ago
no problem!
Budi
BudiOP3mo ago
dbgate is perfect for my needs. Will rock that for now.
Brody
Brody3mo ago
awsome!
Budi
BudiOP3mo ago
Should I close this post? I already tagged as 'solved'.
Want results from more Discord servers?
Add your server