Add railway changes commands - #1000
Open
m-abdelwahab wants to merge 9 commits into
Open
Conversation
New command family (aliases: staged-changes, change) to review, deploy, and discard an environment's staged patch: - status: dashboard-style labels, --path filtering (subtree prefixes, * wildcards, escaped dots), --show-values, --json, --detailed-exit-code - deploy (alias apply): commits via environmentPatchCommitStaged, polls apply progress, warns on resource deletions, enforces 2FA for deletions and volume region moves - discard: --all, repeated --path, or interactive multi-select; partial discard re-stages the remaining patch as raw JSON so fields staged by other clients are preserved Adds an ExitCode sentinel error so --detailed-exit-code can exit 2 without printing an error while still running end-of-process work. The EnvironmentStagedChanges query gains createdAt/updatedAt/ lastAppliedError and decryptVariables.
staged_changes_status, staged_changes_deploy, and staged_changes_discard mirror the CLI commands. Variable values are masked by default in tool output (opt in via show_values); deletions requiring two-factor verification are refused over token auth. Also updates the create_bucket, remove_bucket, and create_tcp_proxy tool descriptions ahead of those operations moving to the staged workflow.
bucket create/delete and tcp-proxy create previously decided between committing immediately and staging based on unmergedChangesCount, which is no longer populated — so they always committed. They now always stage into the environment patch, matching the dashboard, and take effect on railway changes deploy. Deleting a live TCP proxy still applies immediately, also matching the dashboard. bucket delete and tcp-proxy delete additionally detect targets that only exist as staged creations and remove the pending change instead: proxies by staging null over the port entry, buckets by dropping the pending buckets.<id> subtree from the patch (the bucket itself remains at the project level). Applies to the equivalent MCP tools; scale keeps committing immediately as its help documents. Spinners in tcp-proxy create/delete are now only created when stdout is a terminal so success messages print in scripts.
Two fixes on the staging entry path: - CLI flags (--service-config) are now checked before piped stdin. Previously a non-terminal stdin was read first, so scripts passing flags silently staged nothing and exited 0. The 'No changes to apply' message also prints in non-interactive mode now. - Stdin JSON keyed by service name is resolved to the service ID before staging. Previously the patch was staged under the name key, which rendered as a duplicate resource group and produced a patch other clients don't recognize. Unknown services error with the available list; configuring one service by both name and ID is rejected. Staging output now points at railway changes for review and deploy.
Flows that stage changes (outbound IPv6, config apply) printed 'commit with railway environment edit' style hints. They now emit the shared staged-changes notice pointing at railway changes status/deploy.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR gives the CLI first-class support for Railway's staged-changes workflow through a new
railway changescommand family to review, deploy, and discard an environment's staged patch.Command surface
Global on all subcommands:
-p/--projectand-e/--environment, defaulting to the linked project and environment.Behavior
statusrenders staged changes with dashboard-style labels, raw dot paths, and current/new values. It supports subtree and wildcard path filtering, masked variables by default, JSON output, and Terraform-style detailed exit codes.deploycommits the complete staged patch and polls its apply progress. It supports custom messages, skipping deploys, destructive-change warnings, and 2FA when required.discardcan remove the whole patch, selected paths, or an interactive multi-selection. Partial discard re-stages the remaining raw JSON patch so fields created by other clients are preserved.Supporting changes
EnvironmentPatchCommitStagedand raw-configEnvironmentStageChangesRawmutations.EnvironmentStagedChangeswith timestamps, apply errors, and optional variable decryption.errors::ExitCodesentinel so--detailed-exit-codecan return a non-zero status without printing an error or skipping end-of-process work.Follow-up
This PR intentionally defers the following work to follow-up PRs:
Validation
cargo fmt --all -- --checkcargo checkcargo test— 420 passedrailway changesand itsstatus,deploy, anddiscardsubcommands.🤖 Generated with Claude Code