---
title: "Working with NX, Railway and CI/CD"
description: "A GitHub Actions workflow can deploy only the NX monorepo apps affected by a push to Railway, replacing Railway's built-in GitHub trigger."
url: "https://swe.quest/articles/working-with-nx-railway-and-ci-cd-0bc2b769ee29696c"
canonical: "https://blog.railway.com/p/nx-railway-with-gh-actions"
source: "Railway"
published: "2022-09-16"
difficulty: "medium"
kind: "How-to"
reading_minutes: 3
tags: ["ci-cd","deployment","build-systems","javascript"]
---

# Working with NX, Railway and CI/CD

A post on [Railway](https://swe.quest/sources/railway.md), published 2022-09-16, 3 min read, How-to. Original: [https://blog.railway.com/p/nx-railway-with-gh-actions](https://blog.railway.com/p/nx-railway-with-gh-actions)

## Summary

A GitHub Actions workflow can deploy only the NX monorepo apps affected by a push to Railway, replacing Railway's built-in GitHub trigger. The setup sets NIXPACKS\_NX\_APP\_NAME, creates one Railway environment and project token per branch, and stores the tokens as GitHub secrets named RAILWAY\_TOKEN\_\_\<project\>\_\<environment\>. On each push the workflow works out a base commit that survives force pushes, then lints and builds the affected projects. A bash script uses \`nx print-affected\` to find the affected apps, looks up each app's token from a dumped secrets JSON file, and runs \`railway up --detach\`. Dumping the secrets to a file is flagged as risky in public repos, and \`--detach\` keeps long container builds from using up GitHub Actions minutes.

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)
- [Build systems](https://swe.quest/tags/build-systems.md) (Engineering practices)
- [JavaScript](https://swe.quest/tags/javascript.md) (Languages)

## Prerequisites

- GitHub Actions workflows ([easy posts on CI/CD](https://swe.quest/tags/ci-cd.md?difficulty=easy))
- NX monorepos
- Bash scripting

## Keywords

NX, Railway, GitHub Actions, Nixpacks, Railway CLI, pnpm

## 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.
- [Using GitLab CI/CD with Railway](https://swe.quest/articles/using-gitlab-ci-cd-with-railway-8ac9ff086ab7cb53.md): Railway · 2022-08-20 · Medium · 2 min read · CI/CD, Deployment
  Deploying to Railway from GitLab CI/CD comes down to a project token plus a small job that runs the Railway CLI.
- [Enabling branch deployments through IssueOps with GitHub Actions](https://swe.quest/articles/enabling-branch-deployments-through-issueops-with-github-actions-8c407fc129221de6.md): GitHub Engineering · 2023-02-02 · Medium · 6 min read · Deployment, CI/CD, Infrastructure as code
  GitHub's branch-deploy Action brings the branch deploy model to any repository through IssueOps: comment commands like \`.deploy\` or \`.deploy noop\` on a pull request trigger a GitHub Actions workflow that deploys the branch before it is merged.
- [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.
- [Using GitHub Actions with Heroku Flow for additional Security Control](https://swe.quest/articles/using-github-actions-with-heroku-flow-for-additional-security-control-fea72ed977a6f5e4.md): Heroku Engineering · 2025-03-27 · Medium · 7 min read · CI/CD, Deployment, Security, Cloud platforms
  Because GitHub Orgs can't allowlist Heroku IP ranges, Heroku offers a sample pattern: a self-hosted GitHub Actions runner deployed as a Docker app in a Heroku Private Space with static outbound IPs, plus a Heroku Flow Action.

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)
