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
14 Replies
Project ID:
21f7dffb-40ae-442b-b910-de3a32f4f007
21f7dffb-40ae-442b-b910-de3a32f4f007
have you tried passing in the team token the same way you are passing in the environment token?
Good idea - unfortunately just tried it and no luck
what error do you get
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
so just an overview, you want to be able to railway up into any arbitrary environment?
Yep, exactly
okay, ill see if i can come up with something
Amazing, thank you! ❤️
the cli will use two kinds of variables
RAILWAY_API_TOKEN
and RAILWAY_TOKEN
have you tried both?Yep
@milo / salvage - any idea here?
nope, im pretty sure the way it works currently is borken