feat: add rollback command for instantly rolling back to previous deployments#163
Merged
Conversation
chhavi-mandowara-cstk
approved these changes
May 18, 2026
anujachordiya-contentstack
approved these changes
May 18, 2026
🔒 Security Scan Results
⏱️ SLA Breach Summary
✅ BUILD PASSED - All security checks passed |
There was a problem hiding this comment.
Pull request overview
Adds a new launch:rollback command to enable “instant rollback” to a prior deployment, including interactive selection/review prompts and the supporting GraphQL operations + tests.
Changes:
- Introduces a new rollback command (
src/commands/launch/rollback.ts) that resolves org/project/environment, selects an eligible prior deployment, confirms, and triggers a rollback mutation. - Extends GraphQL queries/mutations to support rollback (adds
rollbackDeploymentMutation, and conditionally fetches rollback-related deployment fields fromenvironmentsQuery). - Adds unit tests for rollback behavior (Mocha/Sinon + Jest) and updates
.talismanrcto ignore the new test fixtures.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/commands/launch/rollback.ts |
Implements the new rollback command flow and related UI prompts/output. |
src/graphql/queries.ts |
Adds rollback-relevant fields to latestLiveDeploymentQuery and makes rollback fields in environmentsQuery conditionally selectable. |
src/graphql/mutation.ts |
Adds and exports rollbackDeploymentMutation. |
test/unit/commands/rollback.test.ts |
Adds Mocha/Sinon unit coverage for rollback CLI execution paths. |
src/commands/launch/rollback.test.ts |
Adds Jest unit coverage for core rollback logic/error handling. |
.talismanrc |
Ignores the newly added test files for secret scanning via checksum entries. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+53
to
+76
| async run(): Promise<void> { | ||
| if (!this.flags.environment) { | ||
| await this.getConfig(); | ||
| } | ||
|
|
||
| if (!this.sharedConfig.currentConfig?.uid) { | ||
| await selectOrg({ | ||
| log: this.log, | ||
| flags: this.flags, | ||
| config: this.sharedConfig, | ||
| managementSdk: this.managementSdk, | ||
| }); | ||
| await this.prepareApiClients(); // NOTE update org-id in header | ||
| await selectProject({ | ||
| log: this.log, | ||
| flags: this.flags, | ||
| config: this.sharedConfig, | ||
| apolloClient: this.apolloClient, | ||
| }); | ||
| await this.prepareApiClients(); // NOTE update project-id in header | ||
| } | ||
|
|
||
| await this.rollbackDeployment(); | ||
| } |
Comment on lines
+109
to
+137
| try { | ||
| await this.apolloClient.mutate({ | ||
| mutation: rollbackDeploymentMutation, | ||
| variables: { | ||
| input: { | ||
| deployment: target.uid, | ||
| environment: environment.uid, | ||
| ...(reason ? { reason } : {}), | ||
| }, | ||
| }, | ||
| }); | ||
| } catch (error: unknown) { | ||
| const err = error as { graphQLErrors?: { extensions?: { exception?: { name?: string } } }[]; message?: string }; | ||
| const code = err?.graphQLErrors?.[0]?.extensions?.exception?.name || err?.message; | ||
| this.log(`Rollback failed. Please try again. (${code})`, 'error'); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| ux.print(''); | ||
| ux.print( | ||
| `Promoting deployment ${chalk.cyan(`#${target.deploymentNumber}`)} ` | ||
| + chalk.dim(`(${target.uid})`) + '…', | ||
| ); | ||
|
|
||
| ux.print(''); | ||
| ux.print(chalk.green('✔ Instant rollback to a previous deployment is successful.')); | ||
| const label = `${chalk.cyan(`#${target.deploymentNumber}`)} ${chalk.dim(`(${target.uid})`)}`; | ||
| ux.print(` Deployment ${label} is now ${chalk.green('LIVE')}.`); | ||
| ux.print(''); |
| }) as any); | ||
| }); | ||
|
|
||
| afterEach(() => { |
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.
No description provided.