2 years ago
I created a simple script to deploy my backend using github actions and workflow. Could someone help me?
Deploy do Backend na Railway
deploy-backend:
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '18.x'
- name: Install Railway CLI
run: npm install -g @railway/cli
- name: Inject Railway Token
env:
RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }}
run: echo "RAILWAY_TOKEN is set up."
- name: Deploy Backend on Railway
working-directory: ./packages/backend
run: railway up97 Replies
2 years ago
2 years ago
what seems to be the issue?
Well, you could skip the entire install node/cli part by using the docker image directly
2 years ago
I am looking to create a script with CI to deploy just the backend on railway. I created a Monorepo and the frontend is on vercel and backend should be in Railway
deploy-job:
runs-on: ubuntu-latest
container: ghcr.io/railwayapp/cli:latest
env:
SVC_ID: my-service
RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }}
steps:
- uses: actions/checkout@v3
- run: railway up --service=${{ env.SVC_ID }}two major differences are:
- use docker image directly instead of installing the cli via npm
--serviceflag that tells to which service to deploy
2 years ago
Awesome I will 😄
you'd only need to update working directory to the one containing your actual code
2 years ago
Run railway up --project=1838b8e6-6a84-4a60-9033-3b38888c4746
error: unexpected argument '--project' found
tip: to pass '--project' as a value, use '-- --project'
Usage: railway up [OPTIONS] [PATH]
For more information, try '--help'.
Error: Process completed with exit code 2.
2 years ago
I received this error on Github CI terminal
when running in ci mode you need to provide project token with RAILWAY_TOKEN env var and a service name with --service argument
2 years ago
Run railway up --service=1838b8e6-6a84-4a60-9033-3b38888c4746
Service not found
Error: Process completed with exit code 1.
honestly I don't remember if we support account-scoped access tokens and setting project id via a flag atm
because at the time when I was working on fixing ci mode, adding support for that would involve rewriting too much stuff
2 years ago
Great, helped me. I will change here
2 years ago
could i ask why you arent using the default Railway's build system?
2 years ago
I would like to make a CI in a Monorepo send a project Next to Vercel and Backend on Railway
2 years ago
but you can deploy a monorepo on Railway
2 years ago
2 years ago
Okay so do you have a example of CI like a file I sent here?
umm if you wanna use monorepo support you don't need to configure gh actions, it's configured in railway dashboard
you gotta link a repo to a service first, and then play with the settings a bit
2 years ago
The deploy didn't work using github/actions
2 years ago
I would like to understand better,and I tried a lot to learn how solve it.
2 years ago
But I quit haha I have been try to deploy using countinous integrations and I believe is really hard to deploy.
2 years ago
Thank you everybody to try help me.
2 years ago
Hello @maddsua, how are you? Could we talk about the deploy again?
2 years ago
hey, im still confused on why you're not using the Railway's build system.
do you want to run tests and everything before deploying?
2 years ago
Thalles I am using Railway
2 years ago
But with CI
2 years ago
I need to deploy just the backend on Railway.app
2 years ago
And I used the interface settings and follow the steps
2 years ago
but didn't work
2 years ago
what steps went wrong while trying this?
https://docs.railway.com/guides/monorepo
you dont need a CI at all for deploying a specific app inside a monorepo
2 years ago
I follow this link before
2 years ago
i deploy my backend on Railway and nextjs app on vercel with that
2 years ago
I changed the settings properly
2 years ago
what issues did you have then?
2 years ago
are you using turborepo?
2 years ago
the ci on github actions is that

2 years ago
On the railway is the other picture
2 years ago
wait a secound
2 years ago
thats the thing, you dont need Github Actions at all for this
2 years ago
So I follow the link before that
2 years ago
and didn't work again
2 years ago
what i have to change?
2 years ago
Deploy is npm run start:build
2 years ago
ok lets start from the beginning, are you using turborepo?
2 years ago
No I am not using turborepo. I createad using workspaces
2 years ago
created*
2 years ago
But is not a problem. Because the deploy on vercel is working
2 years ago
I would like to use the same with Railway
2 years ago
without learn other tool or method
2 years ago
2 years ago
I would like to use the same idea that is working on vercel
2 years ago
If Railway doesn't have support I believe is not about my idea
2 years ago
I followed this link before
2 years ago
ok, pretty sure you dont need --auto-approve then
2 years ago
railway up should just get your code and push it
2 years ago
Yeah but didn't work
2 years ago
if you want your Github Actions to wait for your build to complete, you can use --ci
2 years ago
what didnt worked?
2 years ago
Is there some example that I could follow?
2 years ago
none that i know
2 years ago
I got it. I will try again
2 years ago
But is hard back and back the same issue
2 years ago
Deploy should be easy
2 years ago
feel you, unfortunately there's no example right now
and that blog post is outdated
hey im confused with what's not working here. is --auto-approve even a real argument?
2 years ago
no, he's following an outdated blog post
if you push from the cli railway has no way of applying any git contributor restrictions
2 years ago
yeah, confused on what issue he's getting
also, since the cli now has it's own docker image, there's no need to use npm
deploy-job:
runs-on: ubuntu-latest
container: ghcr.io/railwayapp/cli:latest
env:
SVC_ID: my-service
RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }}
steps:
- uses: actions/checkout@v3
- run: railway up --service=${{ env.SVC_ID }}2 years ago
im with thalles on this, i dont know why you need railway up here, attach the repo to your railway service and set the correct config
a year ago
Well, it's very confusing and it seems like I'm not being clear in the way I'm explaining the problem.
My intention was to do a continuous integration using github actions, that's the goal.
From what I understand, I need to go to the platform to get the token and insert it into my github actions. However, when I do the deployment, the service is not created on the platform and there are several impediments, whether command or support.
The big question, have you managed to do the deployment the way I'm describing?
If so, do you have any example files that I can analyze the codes for, or do you want mine to analyze?
I don't use turbo repo, but workspaces in the package.json of the root folder. In vercel, a small frontend test worked, I tried to put the backend there and it didn't work, so I wanted to fix it in another location, which would be the railroad.
But no other platform is helping me with this specific problem. Did you manage to see the problem?
a year ago
you can simply have railway wait on your CI -
a year ago
I don't see why railway up is needed, sorry
a year ago
I just followed the other link on the blog. Okay I remove this command. So I only need to run deploy again?
a year ago
is the source of your service your GitHub repo?
a year ago
I can only share the file
a year ago
i'm sorry but we are all just repeating ourselves and getting nowhere, we all wish you good luck as you solve this!
a year ago
Thank you
a year ago
Hi everyone, we're trying to deploy a service to our Railway account using the following Github Action but keep seeing the error Project Token not found. We've set the ${{ secrets.RAILWAY_TOKEN }} value to a token created from the project settings page, not sure what else we should do?
deploy:
runs-on: ubuntu-latest
container: ghcr.io/railwayapp/cli:latest
env:
RAILWAY_ENVIRONMENT_ID: 48416f8b-40ed-4980-befc-e4222e83697e
RAILWAY_SERVICE_ID: db5c7057-6541-4842-bb57-49135ce5bd0f
RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }}
steps:
- uses: actions/checkout@v4
- run: |
railway up --ci \
--environment=$RAILWAY_ENVIRONMENT_ID \
--service=$RAILWAY_SERVICE_ID
Status changed to Solved adam • 12 months ago
