Build / Deploy Hooks or similar (for private network)
Anonymous
HOBBYOP

17 days ago

Hello all,

I am looking for a way to have 2 services a frontend that is SSG deployed to railways CDN and a backend CMS, that triggers the frontend to rebuild when its changed? All on railways Private Networking (mainly just not triggering deployments that routes externally)

I have seen this done commonly through "build hooks" / "deploy hooks" to trigger a deployment for this flow. I could technically use those providers for the frontend but railway has been pretty great so far I'd like to keep all of my application services in one place!

It sounds like my options are:

  • Use railways public api to trigger a deployment (x emoji️ exposed on the external network | x emoji adds another service)

  • Set daily scheduled CRON jobs (white_check_mark emoji️ not exposed to external network | x emoji adds multiple unnecessary builds)

  • Manually trigger a redeploy ️(white_check_mark emoji not exposed to external network | x emoji tedious)

  • Host frontend separately off of railway (x emoji️ exposed deploys on the external network | x emoji adds another hosting provider)

Any thoughts on what I can do?

$10 Bounty

Pinned Solution

domehane
FREETop 1% Contributor

17 days ago

Hello,

in your cms, whenever content is saved/published, make an outbound call to railway's graphql api using the serviceInstanceRedeploy mutation with your frontend's serviceId and environmentIdsince it's an outbound call from your cms, none of your services need a public url , it just calls railway's api the same way you'd call any external api

this is basically your own "build hook" living inside your cms logic , triggered exactly when you need it, no extra service, no crons, no manual redeploys. everything stays on railway

for the exact mutation syntax and how to get your ids and token, the docs at docs.railway.com/guides/manage-services and docs.railway.com/guides/public-api have everything you need to put it together

Hope this help you :)

4 Replies

Railway
BOT

17 days ago

We don't have a built-in "deploy hook" URL feature, but your CMS backend can call our public API's serviceInstanceRedeploy or environmentTriggersDeploy mutation to trigger a frontend rebuild - this is documented at Manage Deployments with the Public API. The API call is an outbound HTTPS request from your CMS to our API, so your services themselves don't need public domains, though the CMS does need outbound internet access which all services have by default.


Status changed to Awaiting User Response Railway 17 days ago


Status changed to Awaiting Railway Response Railway 17 days ago


Status changed to Open Railway 17 days ago


domehane
FREETop 1% Contributor

17 days ago

Hello,

in your cms, whenever content is saved/published, make an outbound call to railway's graphql api using the serviceInstanceRedeploy mutation with your frontend's serviceId and environmentIdsince it's an outbound call from your cms, none of your services need a public url , it just calls railway's api the same way you'd call any external api

this is basically your own "build hook" living inside your cms logic , triggered exactly when you need it, no extra service, no crons, no manual redeploys. everything stays on railway

for the exact mutation syntax and how to get your ids and token, the docs at docs.railway.com/guides/manage-services and docs.railway.com/guides/public-api have everything you need to put it together

Hope this help you :)


domehane

Hello,in your cms, whenever content is saved/published, make an outbound call to railway's graphql api using the serviceInstanceRedeploy mutation with your frontend's serviceId and environmentIdsince it's an outbound call from your cms, none of your services need a public url , it just calls railway's api the same way you'd call any external apithis is basically your own "build hook" living inside your cms logic , triggered exactly when you need it, no extra service, no crons, no manual redeploys. everything stays on railwayfor the exact mutation syntax and how to get your ids and token, the docs at docs.railway.com/guides/manage-services and docs.railway.com/guides/public-api have everything you need to put it togetherHope this help you :)

Anonymous
HOBBYOP

15 days ago

Dang its not exactly what I was hoping for, I wish railway supported this out of the box but I'll go with this solution for now. Thank you!


Status changed to Solved brody 15 days ago


domehane

Hello,in your cms, whenever content is saved/published, make an outbound call to railway's graphql api using the serviceInstanceRedeploy mutation with your frontend's serviceId and environmentIdsince it's an outbound call from your cms, none of your services need a public url , it just calls railway's api the same way you'd call any external apithis is basically your own "build hook" living inside your cms logic , triggered exactly when you need it, no extra service, no crons, no manual redeploys. everything stays on railwayfor the exact mutation syntax and how to get your ids and token, the docs at docs.railway.com/guides/manage-services and docs.railway.com/guides/public-api have everything you need to put it togetherHope this help you :)

Anonymous
HOBBYOP

13 days ago

Hi again, I was able to get this working. However its not exactly like I expected. I can trigger a serviceInstanceRedeploy to my frontend's serviceId and environmentId but I can't get it it to work with a Project Token which sounds like it should have the correct access based off this chart in the docs. It only works via Workspace Token which it's security isn't scoped as much as I would like. Any ideas?

Heres the error the return gives me when I use a Project Token:
{

message: 'Not Authorized',

locations: [ [Object] ],

path: [ 'serviceInstanceRedeploy' ],

extensions: { code: 'INTERNAL_SERVER_ERROR' },

traceId: '7667170960136540671'

}

similar issue: https://station.railway.com/questions/unable-to-generate-api-token-with-deploy-4d2ccc12


Status changed to Awaiting Railway Response Railway 13 days ago


Status changed to Open brody 13 days ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...