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 }}21 Replies
10 months ago
cdf7b02f-c823-4fae-965a-c72950cfaa1c
10 months ago
Hello,
Are you sure you are using an account token instead of a team or an environment token?
10 months ago
I have a workspace with various projects, I created the token going to Project -> Settings -> Tokens
10 months ago
This command worked:
railway up --ci --service "backend"But thats not the one I want
10 months ago
Its bound to an environment tho
10 months ago
You would want to be using a account token instead
10 months ago
Let me try that
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
10 months ago
Trying locally instead of ci for faster iteration
10 months ago
Are you sure it's an account token? where did you generate it from?
10 months ago
10 months ago
Thats for the link command, for the redeploy one
➜ rt git:(main) railway redeploy --service backend --yes
Project Token not found10 months ago

10 months ago
Ah my bad, wrong variable name -
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 --yes10 months ago
It works locally
10 months ago
Now trying out on the CI
10 months ago
Locally it worked with a project token (the redeploy cmd)
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
10 months ago
Gotcha, thank you for the follow up, much appreciated!
10 months ago
!s
Status changed to Solved brody • 10 months ago