R
Railway•4w ago
IgorKaliel

Deploy using CI/CD Github Actions

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
19 Replies
Percy
Percy•4w ago
Project ID: N/A
IgorKaliel
IgorKalielOP•4w ago
Brody
Brody•4w ago
what seems to be the issue?
maddsua
maddsua•4w ago
Well, you could skip the entire install node/cli part by using the docker image directly Also, you need to provide service name using the respective flag
IgorKaliel
IgorKalielOP•4w 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
maddsua
maddsua•4w ago
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 }}
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: 1. use docker image directly instead of installing the cli via npm 2. --service flag that tells to which service to deploy
IgorKaliel
IgorKalielOP•4w ago
Awesome I will 😄
maddsua
maddsua•4w ago
well, this should work without an issue this is how I deploy my stuff to railway you'd only need to update working directory to the one containing your actual code
IgorKaliel
IgorKalielOP•4w 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. I received this error on Github CI terminal
maddsua
maddsua•4w ago
may I ask what's the --project argument doing there? I don't think the cli even has an arg like that when running in ci mode you need to provide project token with RAILWAY_TOKEN env var and a service name with --service argument
IgorKaliel
IgorKalielOP•4w ago
Run railway up --service=1838b8e6-6a84-4a60-9033-3b38888c4746 Service not found Error: Process completed with exit code 1.
maddsua
maddsua•4w ago
honestly I don't remember if we support account-scoped access tokens and setting project id via a flag atm you need to use service name, not it's id because at the time when I was working on fixing ci mode, adding support for that would involve rewriting too much stuff
IgorKaliel
IgorKalielOP•4w ago
Great, helped me. I will change here
ThallesComH
ThallesComH•4w ago
could i ask why you arent using the default Railway's build system?
IgorKaliel
IgorKalielOP•4w ago
I would like to make a CI in a Monorepo send a project Next to Vercel and Backend on Railway
maddsua
maddsua•4w ago
real unbelievable but there are people who don't deploy everything to railway
ThallesComH
ThallesComH•4w ago
but you can deploy a monorepo on Railway https://docs.railway.app/guides/monorepo
IgorKaliel
IgorKalielOP•4w ago
Okay so do you have a example of CI like a file I sent here?
maddsua
maddsua•4w ago
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
Want results from more Discord servers?
Add your server