Deploy automation
nxfi777
PROOP

8 days ago

Is it possible to automate something like

If service 1 gets redeployed -> redeploy service 2

$10 Bounty

3 Replies

You can set up a custom webhook such that if a specific service is redeployed, it would call Railway’s API to redeploy another service.


bytekeim
PRO

8 days ago

1. add a Webhook in your Railway project.
It will receive a JSON event every time any service deploys.

2. make a small endpoint/server (Node, Python, etc.) to receive that webhook.

3. In that code, check:
“If the deployment event is for Service 1, then redeploy Service 2.”

4. redeploy Service 2 by:

  • running railway redeploy --service service2
    or

  • calling the GraphQL mutation serviceInstanceRedeploy.

so: service 1 deploys → webhook hits your script → script redeploys service 2.


^^ this is also a great way to utilize Railway functions


ghostmanwi
HOBBY

8 days ago

Yes, it is possible to automate redeploying service 2 when service 1 is redeployed on Railway using deployment webhooks and the public GraphQL API.​

Configure a webhook in your Railway project settings (Settings > Webhooks) to send notifications on "DEPLOY" events from service 1 to an intermediary endpoint. This endpoint, hosted on Railway or externally (e.g., n8n or a custom service), parses the payload for service 1's deployment details. It then triggers a redeploy on service 2 via the GraphQL API at https://backboard.railway.app/graphql/v2, authenticating with a project or personal token.​

Example GraphQL mutation for redeploy (via curl or HTTP client):

mutation {
  serviceInstanceRedeploy(serviceId: "SERVICE_2_ID", environmentId: "ENV_ID") {
    status
  }
}

mutation { serviceInstanceRedeploy(serviceId: "SERVICE_2_ID", environmentId: "ENV_ID") { status } }

Use header Authorization: Bearer <YOUR_TOKEN>.​

limitations:

Railway lacks native service dependencies for automatic redeploys between independent services (startup order uses references only). API rate limits apply (e.g., 1000 requests/hour on Hobby plan). Deploy "webhook catcher" templates for simple relays


Loading...