Skip to content
Can't redeploy from CLI

2 years ago

I'm trying to have an action that deploys to Railway - however, even when token is present I can't seem to be able do it.

Unauthorized. Please login with `railway login`
deploy:
    name: Deploy to Railway
    needs: migrate-prod-db
    runs-on: ubuntu-latest
    timeout-minutes: 3
    steps:
      - name: Install Railway CLI
        run: npm install -g @railway/cli
        
      - name: Link to Railway project
        run: railway link --project ${{ secrets.RAILWAY_PROJECT_ID }} --environment production --service backend
        env:
          RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }}
        
      - name: Deploy to Railway
        run: railway redeploy --service backend --yes
        env:
          RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }}
Solved

21 Replies

2 years ago

cdf7b02f-c823-4fae-965a-c72950cfaa1c


2 years ago

Hello,

Are you sure you are using an account token instead of a team or an environment token?


2 years ago

I have a workspace with various projects, I created the token going to Project -> Settings -> Tokens


2 years ago

This command worked:

railway up --ci --service "backend"

But thats not the one I want


2 years ago

Its bound to an environment tho


2 years ago

You would want to be using a account token instead


2 years ago

Let me try that


2 years ago

➜  rt git:(main) export RAILWAY_TOKEN="ACCOUNT_TOKEN_REDACTED"
➜  rt git:(main) railway link --project cdf7b02f-c823-4fae-965a-c72950cfaa1c
Unauthorized. Please login with `railway login`

Same thing happens


2 years ago

Trying locally instead of ci for faster iteration


2 years ago

Are you sure it's an account token? where did you generate it from?



2 years ago

Thats for the link command, for the redeploy one

➜  rt git:(main) railway redeploy --service backend --yes                  
Project Token not found


2 years ago

Ah my bad, wrong variable name -


2 years ago

So my mistake was trying to --link the project in the first place, if I already know the service I can simply

railway redeploy --service backend --yes

2 years ago

It works locally


2 years ago

Now trying out on the CI


2 years ago

Locally it worked with a project token (the redeploy cmd)


2 years ago

Everything worked. Takeaway, all you need is a project scoped token + call redeploy. No need for link, that will fail with a project scoped token


2 years ago

Gotcha, thank you for the follow up, much appreciated!


2 years ago

!s


Status changed to Solved brody • over 1 year ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...