Deployment with Project API Key

samwymaPRO

a year ago

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

0 Replies

samwymaPRO

a year ago

21f7dffb-40ae-442b-b910-de3a32f4f007


a year ago

have you tried passing in the team token the same way you are passing in the environment token?


samwymaPRO

a year ago

Good idea - unfortunately just tried it and no luck


a year ago

what error do you get


samwymaPRO

a year ago

User does not have access to project 21f7dffb-40ae-442b-b910-de3a32f4f007


samwymaPRO

a year ago

I've double checked and I'm using a team token


samwymaPRO

a year ago

And it can list services in the environments with that token


a year ago

so just an overview, you want to be able to railway up into any arbitrary environment?


samwymaPRO

a year ago

Yep, exactly


a year ago

okay, ill see if i can come up with something


samwymaPRO

a year ago

Amazing, thank you! ❤️


a year ago

the cli will use two kinds of variables RAILWAY_API_TOKEN and RAILWAY_TOKEN have you tried both?


samwymaPRO

a year ago

Yep


a year ago

@salvage - any idea here?


a year ago

nope, im pretty sure the way it works currently is borken