Deploying with the CLI
The Railway CLI provides deployment capabilities for both local development workflows and automated CI/CD pipelines.
Quick deploy
The simplest way to deploy is with railway up:
This command scans, compresses, and uploads your app's files to Railway. You'll see real-time deployment logs in your terminal.
Railway will build your code using Railpack or your Dockerfile, then deploy it.
Deployment modes
Attached mode (default)
By default, railway up streams build and deployment logs to your terminal:
This is useful for watching the build process and catching errors immediately.
Detached mode
Use -d or --detach to return immediately after uploading:
The deployment continues in the background. Check status in the dashboard or with railway logs.
CI mode
Use -c or --ci to stream only build logs and exit when the build completes:
This is ideal for CI/CD pipelines where you want to see the build output but don't need to wait for deployment logs. Use --json to output logs in JSON format (also implies CI mode).
Targeting services and environments
Deploy to a specific service
If your project has multiple services, the CLI will prompt you to choose. You can also specify directly:
Deploy to a specific environment
Deploy to a specific project
Use -p or --project to deploy to a project without linking:
Note: When using --project, the --environment flag is required.
CI/CD integration
Using project tokens
For automated deployments, use a Project Token instead of interactive login. Project tokens are scoped to a specific environment and can only perform deployment-related actions.
Some actions you can perform with a project token:
- Deploying code -
railway up - Redeploying a deployment -
railway redeploy - Viewing build and deployment logs -
railway logs
GitHub actions
Railway makes deployment status available to GitHub, so you can trigger actions after deployments complete.
Post-deployment actions
Use the deployment_status event to run commands after Railway deploys your app:
See the GitHub Actions Post-Deploy guide for more details.
PR environments with GitHub actions
Create Railway environments automatically for pull requests:
Note: If you are using a team project, ensure the token is scoped to your account, not a workspace.
See the GitHub Actions PR Environment guide for the complete setup.
Redeploying
Redeploy the current deployment without uploading new code:
This is useful for:
- Applying environment variable changes
- Restarting a crashed service
- Triggering a fresh build with the same code
Deploying a specific path
You can specify a path to deploy:
By default, Railway uses your project root as the archive base. Use --path-as-root to use the specified path as the archive root instead:
When running railway up from a subdirectory without a path argument, Railway still deploys from the project root. To deploy only a specific directory permanently, configure a root directory in your service settings.
Ignoring files
By default, Railway respects your .gitignore file. To include ignored files in your deployment:
Verbose output
For debugging deployment issues:
Related
- CLI Reference - Complete CLI command documentation
- GitHub Autodeploys - Automatic deployments from GitHub
- GitHub Actions Post-Deploy - Run actions after deployment
- GitHub Actions PR Environment - Create environments for PRs