Can't redeploy from CLI
crisog
MODERATOROP

10 months 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

crisog
MODERATOROP

10 months ago

cdf7b02f-c823-4fae-965a-c72950cfaa1c


brody
EMPLOYEE

10 months ago

Hello,

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


crisog
MODERATOROP

10 months ago

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


crisog
MODERATOROP

10 months ago

This command worked:

railway up --ci --service "backend"

But thats not the one I want


crisog
MODERATOROP

10 months ago

Its bound to an environment tho


brody
EMPLOYEE

10 months ago

You would want to be using a account token instead


crisog
MODERATOROP

10 months ago

Let me try that


crisog
MODERATOROP

10 months 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


crisog
MODERATOROP

10 months ago

Trying locally instead of ci for faster iteration


brody
EMPLOYEE

10 months ago

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



crisog
MODERATOROP

10 months ago

Thats for the link command, for the redeploy one

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

crisog
MODERATOROP

10 months ago

1359649598108467500


brody
EMPLOYEE

10 months ago

Ah my bad, wrong variable name -


crisog
MODERATOROP

10 months 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

crisog
MODERATOROP

10 months ago

It works locally


crisog
MODERATOROP

10 months ago

Now trying out on the CI


crisog
MODERATOROP

10 months ago

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


crisog
MODERATOROP

10 months 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


brody
EMPLOYEE

10 months ago

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


brody
EMPLOYEE

10 months ago

!s


Status changed to Solved brody 10 months ago


Loading...