Railway CI/CD CLI Link
jeevenmotion
PROOP

8 months ago

Hi everyone,

Attached is my github workflow.
Nothing crazy, just trying to create a neon branch on pr and then update environment variable in Railway and delete on close. The issue i am running into is here:

Run railway link \
railway link \
--project *** \
--environment "pr-55"
shell: /usr/bin/bash -e {0}
env:
RAILWAYAPITOKEN: ***
LINKPROJECTID: ***
NEONAPIKEY: ***
NEONPROJECTID: ***
NEONPARENTBRANCH: development
Unauthorized. Please login with railway login
Error: Process completed with exit code 1.

Solved$10 Bounty

12 Replies

jeevenmotion
PROOP

8 months ago

68ea58d4-c5c3-4861-9766-674ec6ad9e27


8 months ago

Hey there! So the exact env variable you are sending is RAILWAYAPITOKEN? Thats incorrect, Railway expects RAILWAY_TOKEN. You can alias with: RAILWAY_TOKEN: ${{ secrets.RAILWAYAPITOKEN }}


8 months ago

Past that I'm unsure, would need more info


noahd

Hey there! So the exact env variable you are sending is RAILWAYAPITOKEN? Thats incorrect, Railway expects RAILWAY_TOKEN. You can alias with: RAILWAY_TOKEN: ${{ secrets.RAILWAYAPITOKEN }}

jeevenmotion
PROOP

8 months ago

No, for some reason it's not formatting the variables here properly, the variable is RAILWAY_API_TOKEN, NEON_API_KEY, LINK_PROJECT_ID, NEON_PROJECT_ID, NEON_PARENT_BRANCH


jeevenmotion

No, for some reason it's not formatting the variables here properly, the variable is RAILWAY_API_TOKEN, NEON_API_KEY, LINK_PROJECT_ID, NEON_PROJECT_ID, NEON_PARENT_BRANCH

8 months ago

I just checked around, Someone reported:

To run railway up non-interactively in CI:

  • Use a Project Token (not an Account/Team token).

  • Set it as RAILWAY_TOKEN in your CI environment.

Token types:

  • RAILWAY_API_TOKEN → works for railway whoami, link, etc.

  • RAILWAY_TOKEN (Project Token) → required for railway up, redeploy, logs.

Fix:

  1. Go to Railway → Project → Settings → Tokens → Generate Project Token.

  2. Set it as RAILWAY_TOKEN in your CI.

  3. Run railway up — no login needed.

    Which actions are you doing?


jeevenmotion
PROOP

8 months ago

Railway Link and Railway Variable (Setting a variable)


jeevenmotion

Railway Link and Railway Variable (Setting a variable)

8 months ago

Are you using a user token or project specific token?


jeevenmotion
PROOP

8 months ago

User


jeevenmotion

User

8 months ago

Ah theres your issue! You need to use a project token:
Go to Railway → Project → Settings → Tokens → Generate Project Token.


8 months ago

And project tokens are noted with RAILWAY_TOKEN not RAILWAY_API_TOKEN


jeevenmotion
PROOP

8 months ago

See attached

Attachments


jeevenmotion
PROOP

8 months ago

For anybody reading this thread, don't bother trying to work with the CLI in CI/CD. Spend your time using the GraphQL API, it'll be a lot easier than trying to get the CI/CD to work at the moment.


Status changed to Open itsrems 8 months ago


Status changed to Solved jeevenmotion 8 months ago


Loading...