Does Railway CLI support github branches

jbchangelogs
PROOP

19 days ago

Say I'm on the main branch, and I do railway up vs when I'm on the testing branch and I do the same command. Then maybe I have the same repo deployed twice to projects on railway where each builds and deploys from the respective branches, is the railway CLI able to diffrentiate between the two?

Solved$10 Bounty

3 Replies

Railway
BOT

19 days ago

Hey there! We've found the following might help you get unblocked faster:

If you find the answer from one of these, please let us know by solving the thread!


macuzi
FREE

19 days ago

Hi there! It looks like the CLI can differentiate between environments. For example, the railway link command (see: https://docs.railway.com/reference/cli-api#link) supports an --environment flag:

You can also use the interactive command to switch between environments: railway environment

I came across this thread where someone ran: railway up -e production but it sill got deployed to staging. Turns out that if you’re using RAILWAY_TOKEN in CI/CD, that token is bound to a specific environment when created, which overrides the -e flag—just something to watch out for.

From what I can tell (and anyone can confirm/deny), Railway doesn't directly work with branches - instead it uses environments, and you configure which GitHub branch gets triggered for each environment. From the Github auto deploy docs:

"Services that are linked to a Github repo automatically deploy when new commits are detected in the connected branch."

Their docs on environments are here. I’m planning to test this myself later this week to confirm, but based on the docs, this should help you get started! Feel free to me know if you run into any issues!


macuzi

Hi there! It looks like the CLI can differentiate between environments. For example, the railway link command (see: https://docs.railway.com/reference/cli-api#link) supports an --environment flag:You can also use the interactive command to switch between environments: railway environmentI came across this thread where someone ran: railway up -e production but it sill got deployed to staging. Turns out that if you’re using RAILWAY_TOKEN in CI/CD, that token is bound to a specific environment when created, which overrides the -e flag—just something to watch out for.From what I can tell (and anyone can confirm/deny), Railway doesn't directly work with branches - instead it uses environments, and you configure which GitHub branch gets triggered for each environment. From the Github auto deploy docs:"Services that are linked to a Github repo automatically deploy when new commits are detected in the connected branch."Their docs on environments are here. I’m planning to test this myself later this week to confirm, but based on the docs, this should help you get started! Feel free to me know if you run into any issues!

jbchangelogs
PROOP

18 days ago

Yeahhh this worked! Had to make a new environment on the railway dashboard, named it testing.

Then I used railway link --environment testing  for testing branch which builds from testing branch of the repo and railway link --environment production for the same repo that builds from main branch.

So doing railway up from the different branches is building for the environment it needs. Thanks so much!


Status changed to Solved brody 18 days ago


Loading...