R
Railway6mo ago
Mirand

Railway login

hello, i have a question when using Github Actions to deploy the app to the Railway. I have currently on Railway frontend, backend. i want to use a workflow when anything is changed on the code for backend or frontend. i have generated a token from dashboard, and i saved on the github secrets, and tried: - name: Deploy to Railway run: | railway up --service NestJs Generic TQUEEN env: RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }} this one to login, but the workflow is not able to log in and deploy the app. Also, i have used railway login --token, but is saying that --token is not recognized. please let me know which one is correct way in order to configure login for specific service on Github Actions.
18 Replies
Percy
Percy6mo ago
Project ID: N/A
Mirand
Mirand6mo ago
N/A
MantisInABox
MantisInABox6mo ago
I have not done github actions for deploy, but have you checked the railway docs? https://blog.railway.app/p/github-actions
Railway Blog
Using Github Actions with Railway
Github Actions come with a pretty neat set of features to automate your workflows. In this post, we talk about using Github Actions to automate your deployments on Railway.
Mirand
Mirand6mo ago
Yes i went through this documentation. i found on this document the login like this: - name: Deploy run: railway up env: RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }} - but however on my side is not working. i have 2 services already running on the Railway, so i wanted that new deployment to be done through Github Actions
MantisInABox
MantisInABox6mo ago
Can you share your GitHub action code in full? Make sure you wrap it in ```
Mirand
Mirand6mo ago
name: Railway_Deploy on: push: branches: - back-staging jobs: backend-job: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Install yarn run: npm install -g yarn - name: Install dependencies run: yarn install - name: Build run: yarn run build - name: Reset current Database status run: npx prisma migrate reset --force env: DATABASE_URL: ${{ secrets.STAGING_DATABASE_URL }} - name: Apply all pending migrations to the database run: npx prisma migrate deploy env: DATABASE_URL: ${{ secrets.STAGING_DATABASE_URL }} - name: Install Railway CLI
run: npm install -g @railway/cli - name: Deploy to Railway run: | railway up --service NestJs Generic TQUEEN env: RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }}
MantisInABox
MantisInABox6mo ago
Can you please put a ``` before and after the action code, the formatting is not proper and it is hard to read Also, is there a reason you are wanting to use a GitHub action to deploy, instead of deploying directly from your repo inside of railway? You can set the branch to deploy from in your service
MantisInABox
MantisInABox6mo ago
It also looks like you might be missing a really important step in your flow... I circled the example here for you
No description
Mirand
Mirand6mo ago
just wanted that everything firt to be build on the github actions, and if successfully then deploy to Railway. I don't want automatic deployment since there could be any error on the code and deploying directly to the Railway sometimes build doesn't work and it will crash. the workflow is only failing when trying to deploy to Railway
MantisInABox
MantisInABox6mo ago
If a build fails, it doesn't take your site offline though That's why they use green/blue deploys
Mirand
Mirand6mo ago
my database is also on railway, so i'm using prisma schema to deploy migrations from my github to the db on railway. this step is recomanded to be done through a workflow also
MantisInABox
MantisInABox6mo ago
You can do that with the CLI from your local machine using the shell command Again,I don't use GitHub actions
Mirand
Mirand6mo ago
you can, but this step is recomanded through a CI/CD based on the documentation.
No description
MantisInABox
MantisInABox6mo ago
And you got your token from the project settings, and from your user settings?
Mirand
Mirand6mo ago
No description
Mirand
Mirand6mo ago
this token is saved then on github secrets.
MantisInABox
MantisInABox6mo ago
Ok. Unfortunately I'm out of ideas on why it is not working for you
Mirand
Mirand6mo ago
https://github.com/marketplace/actions/railway-deploy - in case anyone would ask you in future again for Github Actions deployment - refer to this link ;).
GitHub
Railway Deploy - GitHub Marketplace
Simple Action to Deploy Railway App using Railway CLI