R
Railway9mo ago
Sam W

Deployment with Project API Key

Hi there! I'm running to an issue where it seems that you can't create a new deployment using a project team api token (RAILWAY_API_TOKEN when using the cli program, not RAILWAY_TOKEN). The url is "https://backboard.{hostname}/project/{}/environment/{}/up?serviceId={}" (copied from the cli program code), and I get a 401 when trying to perform the operation. In the docs about the public api it doesn't say anywhere that the team api token can't be used to create new deployments, but my experience suggests that you either need a project token or to login manually in the cli. My use case is as follows: we deploy from the cli in a github actions workflow as it gives us a finer grained control over the deployment process, as opposed to using the automated deployments from a repository. When a branch is pushed, if there is a environment with the same name as the branch in railway, we'd like to deploy the code in that branch to the corresponding environment. Seems simple enough. But, since a project token is linked to a specific environment, you can't deploy to the target environment (in fact, it just silently deploys to the environment the token is linked to, even if you try specify another environment - very dangerous behaviour!). Managing a token per environment seems like a lot of work, so we'd much prefer it if the team api token just worked for deployments. Any help/clarification from anyone would be much appreciated! Cheers
Railway Docs
Use the Public API | Railway Docs
Documentation for Railway
14 Replies
Percy
Percy9mo ago
Project ID: 21f7dffb-40ae-442b-b910-de3a32f4f007
Sam W
Sam W9mo ago
21f7dffb-40ae-442b-b910-de3a32f4f007
Brody
Brody9mo ago
have you tried passing in the team token the same way you are passing in the environment token?
Sam W
Sam W9mo ago
Good idea - unfortunately just tried it and no luck
Brody
Brody9mo ago
what error do you get
Sam W
Sam W9mo ago
User does not have access to project 21f7dffb-40ae-442b-b910-de3a32f4f007 I've double checked and I'm using a team token And it can list services in the environments with that token
Brody
Brody9mo ago
so just an overview, you want to be able to railway up into any arbitrary environment?
Sam W
Sam W9mo ago
Yep, exactly
Brody
Brody9mo ago
okay, ill see if i can come up with something
Sam W
Sam W9mo ago
Amazing, thank you! ❤️
Brody
Brody8mo ago
the cli will use two kinds of variables RAILWAY_API_TOKEN and RAILWAY_TOKEN have you tried both?
Sam W
Sam W8mo ago
Yep
Brody
Brody8mo ago
@milo / salvage - any idea here?
milo
milo8mo ago
nope, im pretty sure the way it works currently is borken
Want results from more Discord servers?
Add your server