10 months ago
Hello, how can I deploy a new project from a repository to which I have access, the documentation does not say how to do it, it only gives me this:
mutation githubRepoDeploy($input: GitHubRepoDeployInput!) {
githubRepoDeploy(input: $input)
}
with these variables
{
"input": null
}
I have tried many times and I can't do it, who can help me?
21 Replies
10 months ago
Hello,
Perhaps you can use the brand new CLI feature to do this? -
https://railway.app/changelog/2024-11-08-railway-cli-updates#railway-cli-updates
Status changed to Awaiting User Response Railway • 10 months ago
10 months ago
Can I deploy projects through cli, managing it from a server?
I explain to you, I have a server which I need to deploy small microservices through a server path in express JS, with the API I see that it does not allow me to deploy repositories that are not public, I ask you, can I do it by cli on a server that I mount in the cloud? ?
Status changed to Awaiting Railway Response Railway • 10 months ago
10 months ago
You absolutely can deploy Private GitHub repos from the API.
Check out our graphql playground -
Status changed to Awaiting User Response Railway • 10 months ago
10 months ago
I ask because I just tried graphiql and it gave me this error
"errors": [
{
"message": "Only public repos can be deployed via the URL",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"githubRepoDeploy"
],
"extensions": {
"code": "INTERNAL_SERVER_ERROR"
},
"traceId": "4776896212319822070"
}
],
"data": null
}
Status changed to Awaiting Railway Response Railway • 10 months ago
Status changed to Awaiting User Response Railway • 10 months ago
10 months ago
These are what the documentation says
{
"input":
{
"branch": "main",
"projectId": "45074939",
"repo": "delcas/repo"
}
}
Status changed to Awaiting Railway Response Railway • 10 months ago
Status changed to Awaiting User Response Railway • 10 months ago
Status changed to Awaiting Railway Response Railway • 10 months ago
10 months ago
That would be the wrong mutation, and the wrong variables for what you want.
Tell me what you want to do from start to finish.
Status changed to Awaiting User Response Railway • 10 months ago
10 months ago
I already have some repositories linked, of which I manually deploy that repository when I need to and insert the environment variables. I want to do the same thing but automated by API, which tells it which repository to deploy.
the repositories in my github account are private but allowed on rail
Status changed to Awaiting Railway Response Railway • 10 months ago
10 months ago
I'm sorry but that does not provide enough information for me to action on, please tell me what you want to happen from start to finish, preferably in steps.
Status changed to Awaiting User Response Railway • 10 months ago
10 months ago
Ok, I'll explain:
1. I have a server where a user registers, creates a user.
2. after creating the user, a service must be deployed to that user
3. With a server route using the Rail API you must deploy a repository.
4. With the user's data, the environment variables are created for that service of that user.
5.once the deployment is done, the public url must be generated
6.Once finished it should return the deployment ID and its public url.
Currently I have 20 micro services and but they have been created manually I need to automate it because I hope to reach more than 200 in 2 months, if I can't do it through the railway API I will have to migrate to another platform
Status changed to Awaiting Railway Response Railway • 10 months ago
10 months ago
2. after creating the user, a service must be deployed to that user
I assume you mean you want to deploy this service into your own project on behalf of the user?
Status changed to Awaiting User Response Railway • 10 months ago
10 months ago
I currently do this manually, I need to automate it through API, that is, I need to know what the QUERY or the MUTATION is to deploy a repository
Attachments
Status changed to Awaiting Railway Response Railway • 10 months ago
Status changed to Awaiting User Response Railway • 10 months ago
10 months ago
ok I will wait, if you can sooner I would appreciate it
Status changed to Awaiting Railway Response Railway • 10 months ago
Status changed to In Progress brody • 10 months ago
10 months ago
Hello, here are the mutations you will need to deploy a service from a private GitHub repo (That you own), with variables, and then generate a domain for it.
To create a service and deploy the defined repo -
mutation ServiceCreate($name: String, $projectId: String!, $environmentId: String!, $source: ServiceSourceInput, $branch: String, $variables: EnvironmentVariables) {
serviceCreate(
input: {name: $name, projectId: $projectId, environmentId: $environmentId, source: $source, variables: $variables, branch: $branch}
) {
id
name
}
}
{
"name": "<service name>",
"projectId": "<project id>",
"environmentId": "<environment id>",
"source": {
"repo": "<user/org>/<repo name>"
},
"branch": "<branch>",
"variables": {
"HELLO": "WORLD"
}
}
To generate a domain for the newly created service -
mutation ServiceDomainCreate($environmentId: String!, $serviceId: String!) {
serviceDomainCreate(
input: { environmentId: $environmentId, serviceId: $serviceId }
) {
id
domain
}
}
{
"environmentId": "<environment id>",
"serviceId": "<service id returned from last api call>"
}
You can grab all the needed Ids from the command pallet, open up your desired project and environment -> ctrl /cmd + k
-> type Copy
10 months ago
ok thanks, I'll do the test, I only have one question and that is what it is and where do I get it:
"environmentId": "<environment id>",
10 months ago
Hello, thank you very much, it was not as I wanted but thanks to that mutation and those in the documentation I managed to make it perfect as I wanted
10 months ago
I thought I followed your outline to what you described, but I'm happy you were able to find the solution that fit your needs perfectly!
Status changed to Solved brody • 10 months ago