Deploy from gitlab
fra
HOBBYOP

3 hours ago

Hello, I've switched from using Github to Gitlab but I have some issues getting the deployment working, I've tried these options:

deploy:
  stage: deploy
  image: ghcr.io/railwayapp/cli:latest
  variables:
    SVC_ID: "service-id"
  script:
    - railway up --environment=staging --service=$SVC_ID
  script:
    - RAILWAY_TOKEN=$RAILWAY_TOKEN railway up --environment=staging --service=$SVC_ID
  script:
    - export RAILWAY_TOKEN=$RAILWAY_TOKEN
    - RAILWAY_TOKEN=$RAILWAY_TOKEN railway up --environment=staging --service=$SVC_ID

but I'm always getting this error:

Invalid RAILWAY_TOKEN. Please check that it is valid and has access to the resource you're trying to use.

am I doing something wrong? never had issues in github

$10 Bounty

10 Replies

is this a user token or workspace token?


fra
HOBBYOP

3 hours ago

workspace token


Try RAILWAY_API_TOKEN.


fra
HOBBYOP

2 hours ago

if I set the api token then I get:

No linked project found. Run railway link to connect to a project

→ Run railway link to connect to a project.


Railway
BOT

2 hours ago

This thread has been opened as a bounty so the community can help solve it.

Status changed to Open Railway about 2 hours ago


Try doing --environment staging. (Taken from CLI example: railway up --service api --environment production)


fra
HOBBYOP

2 hours ago

yeah I've tried that already but it still doesn't work


whats the error message? still invalid token


fra
HOBBYOP

an hour ago

I've tried locally, doing RAILWAY_TOKEN=xxx railway up --environment staging --service xxx and it is now throwing Unauthorized. Please login with railway login

in the ci I'm getting:

Invalid RAILWAY_TOKEN. Please check that it is valid and has access to the resource you're trying to use.

And I've just tried with a fresh new token


fra
HOBBYOP

39 minutes ago

I might have found the issue, for some reason passing the environment break the up command...I've removed the environment and it seems to work fine 🤔


fra
HOBBYOP

25 minutes ago

one issue I've noticed, but it is related to gitlab not railway (I think), if the variable is masked and hidden it doesn't work 🤷‍♂️


Welcome!

Sign in to your Railway account to join the conversation.

Loading...