Help Implementing Branch Previews for Railway

wetendorffTRIAL

a year ago

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?

0 Replies

wetendorffTRIAL

a year ago

N/A


a year ago

I think <@837759821657931866> has successfully done this exact same thing, though I can't remember if it was with planet scale or neon


faolainPRO

a year ago

Indeed I have thanks for the tag Brody. Hey <@458926567914078210> I created my own GitHub action to do exactly this using neon & railway


faolainPRO

a year ago

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

and then how to use it


faolainPRO

a year ago


faolainPRO

a year ago

and that's the github action on how to use it


wetendorffTRIAL

a year ago

Thanks <@837759821657931866> and @Brody. It looks exactly like what I'm looking for. Thank you very much! I'll try it out later.


faolainPRO

a year ago

You're very welcome!


faolainPRO

a year ago

Xmas gift 😛


wetendorffTRIAL

a year ago

<@837759821657931866> It works like a charm. Thanks again <:1010:1173874936306221126>


faolainPRO

a year ago

you're very welcome!


faolainPRO

a year ago

🙂


wetendorffTRIAL

a year ago

<@837759821657931866> Just one little thing: For some reason, steps.railway_deploy.outputs.domain appears to be empty 🤔


faolainPRO

a year ago

ah sorry about that, I need to update the docs


faolainPRO

a year ago

it's service_domain, not domain that was an older version and I never changed it in the README



faolainPRO

a year ago

just updated the docs for it


wetendorffTRIAL

a year ago

I relied too heavily on IntelliSense 😊 It works now.


faolainPRO

a year ago

haha perfect


faolainPRO

a year ago

I'm going to be doing an update to support multiple services as it's very "naive" now


faolainPRO

a year ago

Would love some railway input though and also some endpoints which would help simplify the steps quite heavily


faolainPRO

a year ago

open to any PRs though


wetendorffTRIAL

a year ago

I also find it strange that it was not possible to make previews with railway cli.


faolainPRO

a year ago

agreed, as it's shown it can be done, it's hacky but it works hehe


faolainPRO

a year ago

Sidenote I pushed another update to handle multiple services, it's also very very rudimentary at the moment and I don't suggest you update if what you have works <@458926567914078210> but I'm setting up infra so that split workers can work alongside an app. Latest is v2.0.4 but imo the action in theory isn't ready for public consumption as it's very shoot from the hip, I'd like something more professional but time is always a bottleneck. In any case if you happen to have multiple running applications in a project v2.0.4 will work (for example a worker app and an api)


a year ago

I'm working on a blog post which covers this. Glad to see that there's interest 😄


a year ago

If you have any Neon-related questions feel free to reach out


a year ago

Hey <@273160359614087168>! Did that blog post end up coming out? 😄


a year ago

I'd love to know if there's an official way to integrate Neon branches with Railway's automatic PR environments


a year ago

I'm still looking into it. The Railway CLI doesn't support preview deployments so I'll need to do something with the API instead


faolainPRO

a year ago

Hey <@273160359614087168> bumping this, https://discord.com/channels/713503345364697088/1188399481507545119/1188592663776219176 we use this live including neon branches & railway


a year ago

oh


a year ago

this is very cool


a year ago

I'll create my own project and try it out. Thanks <@837759821657931866> !