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

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