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

a month 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 (️ exposed on the external network | adds another service)
  • Set daily scheduled CRON jobs (️ not exposed to external network | adds multiple unnecessary builds)
  • Manually trigger a redeploy ️( not exposed to external network | tedious)
  • Host frontend separately off of railway (️ exposed deploys on the external network | adds another hosting provider)

Any thoughts on what I can do?

$10 Bounty

Pinned Solution

domehane
FREE

a month 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

a month 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 about 1 month ago


Status changed to Awaiting Railway Response Railway about 1 month ago


Status changed to Open Railway about 1 month ago


domehane
FREE

a month 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 `environmentId`since 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](http://docs.railway.com/guides/manage-services) and [docs.railway.com/guides/public-api](http://docs.railway.com/guides/public-api) have everything you need to put it together Hope this help you :)

Anonymous
HOBBYOP

a month 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 about 1 month 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 `environmentId`since 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](http://docs.railway.com/guides/manage-services) and [docs.railway.com/guides/public-api](http://docs.railway.com/guides/public-api) have everything you need to put it together Hope this help you :)

Anonymous
HOBBYOP

a month 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 29 days ago


Status changed to Open brody 29 days ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...