Skip to content
How to Connect GitHub to an Empty Service Without Triggering Automatic Deployment
deadtoothtimmy
OP

a month ago

Hi Railway team,

I have an existing Empty Service with no source connected and no deployment history.

I want to connect a private GitHub repository and select a release branch, but I need to ensure:

  1. Connecting the repository does not trigger an initial build or deployment.
  2. Automatic GitHub deployments are disabled before, or atomically with, the connection.
  3. I can later manually deploy one specific Git commit.

Is there a supported dashboard or API procedure that guarantees these conditions?

I have already configured the Dockerfile builder, repository-root directory and Dockerfile path.

Thanks for your help!

Solved

5 Replies

Railway
BOT

a month ago

In the dashboard, connecting a repository to a service starts a deployment when you apply it, so there is no dashboard path that connects the repo without a build. The API's serviceConnect mutation behaves the same way: it always starts a deployment and sets up automatic GitHub deploys.

Through the public GraphQL API, serviceInstanceUpdate with source: { repo: "owner/repo" } in its input writes the repository to the service instance without starting a deployment, and it does not create a deployment trigger, so pushes to GitHub will not deploy the service automatically. Branch-based automatic deploys are managed separately through deployment triggers (deploymentTriggerUpdate and deploymentTriggerDelete), which you can leave absent if you only want manual deploys.

To deploy one specific commit later, call serviceInstanceDeployV2 with your serviceId, environmentId and commitSha; it deploys that commit and returns the new deployment ID. Your existing Dockerfile builder, root directory and Dockerfile path settings stay on the service and are used for that build.


Status changed to Awaiting User Response Railway • about 1 month ago


Railway

In the dashboard, connecting a repository to a service starts a deployment when you apply it, so there is no dashboard path that connects the repo without a build. The API's `serviceConnect` mutation behaves the same way: it always starts a deployment and sets up automatic GitHub deploys. Through the public GraphQL API, `serviceInstanceUpdate` with `source: { repo: "owner/repo" }` in its input writes the repository to the service instance without starting a deployment, and it does not create a deployment trigger, so pushes to GitHub will not deploy the service automatically. Branch-based automatic deploys are managed separately through deployment triggers (`deploymentTriggerUpdate` and `deploymentTriggerDelete`), which you can leave absent if you only want manual deploys. To deploy one specific commit later, call `serviceInstanceDeployV2` with your `serviceId`, `environmentId` and `commitSha`; it deploys that commit and returns the new deployment ID. Your existing Dockerfile builder, root directory and Dockerfile path settings stay on the service and are used for that build.

deadtoothtimmy
OP

a month ago

Thank you! That's very helpful.

Before we proceed, could you please confirm one important detail about serviceInstanceUpdate?

We already have an Empty Service with its Dockerfile builder, root directory and Dockerfile path configured.

We want to associate a private GitHub repository and a specific release branch without triggering any build, deployment or automatic GitHub deployment trigger.

Could you provide:

  1. The exact GraphQL mutation and variables needed to associate both the repository and release branch with this existing service.
  2. Confirmation that this mutation does not implicitly create a deployment trigger or start a deployment.
  3. The GraphQL query to verify afterward that the repository and correct branch are configured, that zero deployment triggers exist, and that deployment history remains empty.

Please distinguish documented API behaviour from anything you're inferring. If any part is uncertain, please say so.

We specifically do not want to use serviceConnect or trigger the first deployment yet.

Thank you!


Status changed to Awaiting Railway Response Railway • about 1 month ago


Railway
BOT

a month ago

For the repository, use the documented serviceInstanceUpdate mutation with input set to { "source": { "repo": "owner/repo" } }. Setting only the repository this way does not start a deployment and does not create a deployment trigger.

The branch cannot be set through that mutation, since its source input takes a repository or image but no branch. On a connected service the branch belongs to a deployment trigger, and a trigger is what makes pushes to that branch deploy automatically, so associating a release branch and having zero triggers are not compatible. There is no option that keeps a trigger while turning off push deploys.

For the manual release a branch is not needed: serviceInstanceDeployV2 with commitSha deploys that exact commit, and an unknown SHA returns "Commit not found" with no deployment created. Always pass the SHA, because without one the repository's default branch is used.

To verify afterwards, the serviceInstance query can return source { repo } and latestDeployment, which should be null. The deploymentTriggers(projectId, environmentId, serviceId) query should return no edges, and deployments(input: { serviceId, environmentId }) should return no edges.


Status changed to Awaiting User Response Railway • about 1 month ago


Status changed to Solved deadtoothtimmy • about 1 month ago


deadtoothtimmy
OP

a month ago

Hi Rails!

We've successfully connected our GitHub repository to an Empty Service using serviceInstanceUpdate, with zero deployment triggers.

We have now configured the Singapore region, Dockerfile builder and Restart Policy: Never.

Our next test will deliberately build one SHA-pinned Docker image and start it without runtime credentials. The application is expected to exit immediately with code 1.

Before doing this, we need to avoid unexpected AI Agent diagnosis charges.

Could you please confirm:

  1. Does Railway automatically invoke the paid AI Agent when a deployment fails at startup, without the user requesting diagnosis?
  2. If so, where can we disable automatic diagnosis before this test?
  3. If there is no disable switch, can we set the Agent usage hard limit to zero or otherwise prevent billable Agent calls?
  4. Does Railway automatically pass a service variable named SOURCE_REVISION as a Docker build argument, or must it be configured separately?

Please give the currently supported dashboard or API procedure, and distinguish verified behaviour from assumptions.

We do not want to deploy or change any settings yet.

Thank you!


Status changed to Awaiting Railway Response Railway • about 1 month ago


Railway
BOT

a month ago

Yes, automatic deployment-failure diagnosis can incur Railway Agent charges even when nobody starts an Agent session manually, so a deliberate exit-code-1 failure could trigger it. We can't point you to a separate switch that turns off just automatic diagnosis. To prevent billable Agent usage, set the Agent hard limit to $0 at Workspace Usage using "Update limits" (or "Set limits" if you haven't configured limits yet). That disables Agent features, so no further Agent charges accrue. It only affects the Agent: the separate Compute hard limit can't go below $10, and your service keeps running normally either way.

On SOURCE_REVISION: service variables are available at build time, but a Dockerfile only receives them when it declares them with ARG. So adding ARG SOURCE_REVISION in the stage that needs it is enough, with no separate build-arg configuration (Dockerfiles docs). Without that ARG line, the variable is not passed to the build.

For your test, the image build itself isn't billed, including failed builds. Normal runtime usage applies only while the container is actually running.


Status changed to Awaiting User Response Railway • about 1 month ago


Status changed to Solved deadtoothtimmy • about 1 month ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...