Skip to content
This repository was archived by the owner on Nov 13, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,28 @@ Version: 3
Status: succeeded
```

**~rollback_app**

If you would like to rollback your app to the code associated with a previous release of your app, you can do so with the ~rollback_app command.

```
you: ~rollback_app testing-nell-bot version-to-rollback-to
```

```
you: ~rollback_app testing-nell-bot v5

crates-io-bot: @you App testing-nell-bot was successfully rolled back to the code at v5
```

You can either specify the version with a "v" before the version number or with just the number. This command will also work.

```
you: ~rollback_app testing-nell-bot 5

crates-io-bot: @you App testing-nell-bot was successfully rolled back to the code at 5
```

**~scale_app**

You can scale formations of dynos within your application through the ~scale_app command.
Expand Down
32 changes: 32 additions & 0 deletions src/commands/heroku.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,38 @@ pub fn get_app_releases(ctx: &mut Context, msg: &Message, mut args: Args) -> Com
Ok(())
}

#[command]
#[num_args(2)]
pub fn rollback_app(ctx: &mut Context, msg: &Message, mut args: Args) -> CommandResult {
let app_name = args
.single::<String>()
.expect("You must include an app name");

let version_to_rollback_to = args
.single::<String>()
.expect("You must include the version to roll back to");

let response = heroku_client(ctx).request(&releases::ReleaseRollback {
app_id: app_name.clone(),
params: releases::ReleaseRollbackParams {
release: version_to_rollback_to.clone(),
},
});

msg.reply(
ctx,
match response {
Ok(_response) => format!(
"App {} was successfully rolled back to the code at {}",
app_name, version_to_rollback_to
),
Err(e) => format!("An error occured when trying to roll back your app:\n{}", e),
},
)?;

Ok(())
}

#[command]
pub fn get_apps(ctx: &mut Context, msg: &Message, _args: Args) -> CommandResult {
let response = heroku_client(ctx).request(&apps::AppList {});
Expand Down
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ use crate::authorizations::users::*;
restart_app,
scale_app,
update_app_config,
get_app_releases
get_app_releases,
rollback_app
)]
struct General;

Expand Down