Help Implementing Branch Previews for Railway
I am currently working on implementing neon branches via GitHub Actions whenever a new pull request is initiated. I've been inspired by the neon demo project "preview-branches-with-vercel." (https://github.com/neondatabase/preview-branches-with-vercel/tree/main)
However, I've encountered a challenge when trying to implement the preview site in Railway. The Railway CLI doesn't have an option for creating environments. I can't use automatically created PR environments, as the neon branch action creates a fresh database URL that the preview site needs to connect to the database.
I've been trying to find a viable workaround or a way to implement this. However, I'm currently stuck and could use some advice. Does anyone have any suggestions on how I could go about this or if a feature/support is planned to enable such workflows within the Railway ecosystem?
GitHub
GitHub - neondatabase/preview-branches-with-vercel: Example project...
Example project that shows how you can create a branch for every preview deployment on Vercel using GitHub actions - GitHub - neondatabase/preview-branches-with-vercel: Example project that shows h...
22 Replies
Project ID:
N/A
N/A
I think @Faolain has successfully done this exact same thing, though I can't remember if it was with planet scale or neon
Indeed I have thanks for the tag Brody. Hey @wetendorff I created my own GitHub action to do exactly this using neon & railway
The action I created is a bit barebones and only supports one service at the moment but I was thinking to expand it maybe this xmas weekend if I find some time but essentially
- https://github.com/Faolain/railway-pr-deploy (for instantiating the environment)
- https://github.com/Faolain/railway-pr-delete (for cleanup)
and then how to use it
GitHub
GitHub - Faolain/railway-pr-deploy
Contribute to Faolain/railway-pr-deploy development by creating an account on GitHub.
GitHub
GitHub - Faolain/railway-pr-delete
Contribute to Faolain/railway-pr-delete development by creating an account on GitHub.
and that's the github action on how to use it
Thanks @Faolain and @Brody. It looks exactly like what I'm looking for. Thank you very much! I'll try it out later.
You're very welcome!
Xmas gift π
@Faolain It works like a charm. Thanks again ![1010](https://cdn.discordapp.com/emojis/1173874936306221126.png)
![1010](https://cdn.discordapp.com/emojis/1173874936306221126.png)
you're very welcome!
π
@Faolain Just one little thing: For some reason,
steps.railway_deploy.outputs.domain
appears to be empty π€ah sorry about that, I need to update the docs
it's
service_domain
, not domain that was an older version and I never changed it in the README
This is where I set it https://github.com/Faolain/railway-pr-deploy/blob/main/index.js#L282
just updated the docs for itI relied too heavily on IntelliSense π It works now.
haha perfect
I'm going to be doing an update to support multiple services as it's very "naive" now
Would love some railway input though and also some endpoints which would help simplify the steps quite heavily
open to any PRs though
I also find it strange that it was not possible to make previews with railway cli.