---
title: "Using GitLab CI/CD with Railway"
description: "Deploying to Railway from GitLab CI/CD comes down to a project token plus a small job that runs the Railway CLI."
url: "https://swe.quest/articles/using-gitlab-ci-cd-with-railway-8ac9ff086ab7cb53"
canonical: "https://blog.railway.com/p/gitlab-ci-cd"
source: "Railway"
published: "2022-08-20"
difficulty: "medium"
kind: "How-to"
reading_minutes: 2
tags: ["ci-cd","deployment"]
---

# Using GitLab CI/CD with Railway

A post on [Railway](https://swe.quest/sources/railway.md), published 2022-08-20, 2 min read, How-to. Original: [https://blog.railway.com/p/gitlab-ci-cd](https://blog.railway.com/p/gitlab-ci-cd)

## Summary

Deploying to Railway from GitLab CI/CD comes down to a project token plus a small job that runs the Railway CLI. Create a project token in the Railway project settings and store it as a secret GitLab CI/CD variable (RAILWAY\_TOKEN). A minimal .gitlab-ci.yml then uses the ghcr.io/railwayapp/cli image to run \`railway up --service=$SVC\_ID\` on pushes to the default branch, while Railway's own infrastructure does the build. Teams can instead build artifacts in GitLab CI and deploy them with the CLI. The token must stay secret, but the service ID can be exposed safely.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [CI/CD](https://swe.quest/tags/ci-cd.md) (Reliability & operations)
- [Deployment](https://swe.quest/tags/deployment.md) (Reliability & operations)

## Prerequisites

- GitLab CI YAML basics ([easy posts on CI/CD](https://swe.quest/tags/ci-cd.md?difficulty=easy))

## Keywords

GitLab CI/CD, Railway, Railway CLI, Nixpacks

## Related posts

- [Using Github Actions with Railway](https://swe.quest/articles/using-github-actions-with-railway-5eb8da35bcdd7f7c.md): Railway · 2021-06-04 · Medium · 2 min read · CI/CD, Deployment
  Railway deployments can be driven from GitHub Actions instead of the built-in branch-push trigger by creating a project token, storing it as a repository secret (RAILWAY\_TOKEN), and running \`railway up --service=\<id\>\` inside the official Railway CLI container.
- [Working with NX, Railway and CI/CD](https://swe.quest/articles/working-with-nx-railway-and-ci-cd-0bc2b769ee29696c.md): Railway · 2022-09-16 · Medium · 3 min read · CI/CD, Deployment, Build systems, JavaScript
  A GitHub Actions workflow can deploy only the NX monorepo apps affected by a push to Railway, replacing Railway's built-in GitHub trigger.
- [Cron Jobs with Django and GitHub Actions](https://swe.quest/articles/cron-jobs-with-django-and-github-actions-51c1dc05687de3cc.md): Railway · 2023-03-22 · Medium · 2 min read · CI/CD, Python, Scheduling
  Scheduled Django management commands can run against a Railway project by using a GitHub Actions workflow on a cron schedule.
- [Manually Optimize Deployments on Railway](https://swe.quest/articles/manually-optimize-deployments-on-railway-a679dfa34223c7fb.md): Railway · 2024-12-13 · Medium · 9 min read · Deployment, CI/CD, Containers, Python
  Deploying a FastAPI app on Railway three ways shows large speed differences: the default Nixpacks builder took 1m27s, a slim-based custom Dockerfile took 15 seconds, and pulling a pre-built image from Docker Hub took 6 seconds.
- [Deploy autoscaling services, AI Workflow automation, and LLM APIs Without Kubernetes](https://swe.quest/articles/deploy-autoscaling-services-ai-workflow-automation-and-llm-apis-without-89990f29298b2ab4.md): Railway · 2025-12-19 · Medium · 15 min read · Kubernetes, Deployment, Containers, CI/CD, Cloud platforms
  Many teams adopting Kubernetes only need to build containers, expose endpoints, scale and observe services, and a managed container platform like Railway can cover those needs with far less operational overhead.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
