24 days ago
hi friends! the way we work on our project is with feature branches, and then before merging into main, we want to deploy that branch to prod for final validation. if all is good, the branch is merged and then we go back to having main be what is deployed.
we are using https://github.com/github/branch-deploy for this to deploy it via a GitHub action.
we tried to do this using railway up, but our app is too big, so that fails because the upload size is too large.
is there an API, or some method, where we can specify that we want to deploy a specific git branch to our production env? or is there some kind of way to accomplish our branch deploy model with railway?
(we don't want to have a separate env per PR/branch, we specifically want to automate being able to deploy a specific branch to prod so we are serving real user traffic)
3 Replies
24 days ago
Sounds like you just need a separate deployment branch (prod) that main gets fast-forwarded to once validation is passed?
24 days ago
Would that be canary deployments?
24 days ago
Yes, you can use Railway GraphQL API to change the connected branch of your production service.
Here is how:
1. Generate a token to authenticate your API requests. Check the Public API Docs
2. Use the serviceConnect mutation query to specify the service you want to modify, github repo and branch.
Here is an example query:mutation {
serviceConnect(
id: "service-id"
input: {repo: "username/repo", branch: "branch-name"}
) {
id
}
}
Don't forget to attach your token to request headers.
To Revert to Main: Run the same mutation but set branch: "main".
You can also use Railway GraphQL Playground to test things out.