6 months 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 up
0 Replies
6 months ago
6 months ago
what seems to be the issue?
Well, you could skip the entire install node/cli part by using the docker image directly
6 months 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
--service
flag that tells to which service to deploy
6 months ago
Awesome I will 😄
you'd only need to update working directory to the one containing your actual code
6 months 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.
6 months 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
6 months 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
6 months ago
Great, helped me. I will change here
6 months ago
could i ask why you arent using the default Railway's build system?
6 months ago
I would like to make a CI in a Monorepo send a project Next to Vercel and Backend on Railway
6 months ago
but you can deploy a monorepo on Railway
6 months ago
6 months 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
5 months ago
The deploy didn't work using github/actions
5 months ago
I would like to understand better,and I tried a lot to learn how solve it.
5 months ago
But I quit haha I have been try to deploy using countinous integrations and I believe is really hard to deploy.
5 months ago
Thank you everybody to try help me.
5 months ago
Hello @maddsua, how are you? Could we talk about the deploy again?
5 months 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?
5 months ago
Thalles I am using Railway
5 months ago
But with CI
5 months ago
I need to deploy just the backend on Railway.app
5 months ago
And I used the interface settings and follow the steps
5 months ago
but didn't work
5 months 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
5 months ago
I follow this link before
5 months ago
i deploy my backend on Railway and nextjs app on vercel with that
5 months ago
I changed the settings properly
5 months ago
what issues did you have then?
5 months ago
are you using turborepo?
5 months ago
the ci on github actions is that
5 months ago
On the railway is the other picture
5 months ago
wait a secound
5 months ago
thats the thing, you dont need Github Actions at all for this
5 months ago
So I follow the link before that
5 months ago
and didn't work again
5 months ago
what i have to change?
5 months ago
Deploy is npm run start:build
5 months ago
ok lets start from the beginning, are you using turborepo?
5 months ago
No I am not using turborepo. I createad using workspaces
5 months ago
created*
5 months ago
But is not a problem. Because the deploy on vercel is working
5 months ago
I would like to use the same with Railway
5 months ago
without learn other tool or method
5 months ago
5 months ago
I would like to use the same idea that is working on vercel
5 months ago
If Railway doesn't have support I believe is not about my idea
5 months ago
I followed this link before
5 months ago
ok, pretty sure you dont need --auto-approve then
5 months ago
railway up should just get your code and push it
5 months ago
Yeah but didn't work
5 months ago
if you want your Github Actions to wait for your build to complete, you can use --ci
5 months ago
what didnt worked?
5 months ago
Is there some example that I could follow?
5 months ago
none that i know
5 months ago
I got it. I will try again
5 months ago
But is hard back and back the same issue
5 months ago
Deploy should be easy
5 months 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?
5 months 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
5 months 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 }}
5 months 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
5 months 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?
5 months ago
you can simply have railway wait on your CI -
5 months ago
I don't see why railway up
is needed, sorry
5 months ago
I just followed the other link on the blog. Okay I remove this command. So I only need to run deploy again?
5 months ago
is the source of your service your GitHub repo?
5 months ago
I can only share the file
5 months ago
i'm sorry but we are all just repeating ourselves and getting nowhere, we all wish you good luck as you solve this!
5 months ago
Thank you