Railway CI/CD CLI Link
jeevenmotion
PROOP

a year 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:

RAILWAY_API_TOKEN: ***

LINK_PROJECT_ID: ***

NEON_API_KEY: ***

NEON_PROJECT_ID: ***

NEON_PARENT_BRANCH: development

Unauthorized. Please login with railway login

Error: Process completed with exit code 1.

Solved$10 Bounty

12 Replies

jeevenmotion
PROOP

a year ago

68ea58d4-c5c3-4861-9766-674ec6ad9e27


a year 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 }}


a year 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

a year 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

a year 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

a year ago

Railway Link and Railway Variable (Setting a variable)


jeevenmotion

Railway Link and Railway Variable (Setting a variable)

a year ago

Are you using a user token or project specific token?


jeevenmotion
PROOP

a year ago

User


jeevenmotion

User

a year ago

Ah theres your issue! You need to use a project token:

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


a year ago

And project tokens are noted with RAILWAY_TOKEN not RAILWAY_API_TOKEN


jeevenmotion
PROOP

a year ago

See attached

Attachments


jeevenmotion
PROOP

a year 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 nico about 1 year ago


Status changed to Solved jeevenmotion about 1 year ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...