Skip to content
This repository has been archived by the owner on May 30, 2024. It is now read-only.

Remove the Slack interaction #275

Merged
merged 4 commits into from
Dec 18, 2021
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
11 changes: 5 additions & 6 deletions cmd/server/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,10 @@ type (
}

Slack struct {
SlackClientID string `split_words:"true"`
SlackClientSecret string `split_words:"true"`
SlackSigningSecret string `split_words:"true"`
SlackUserScopes []string `split_words:"true" default:""`
SlackBotScopes []string `split_words:"true" default:"commands,chat:write"`
SlackClientID string `split_words:"true"`
SlackClientSecret string `split_words:"true"`
SlackUserScopes []string `split_words:"true" default:""`
SlackBotScopes []string `split_words:"true" default:"commands,chat:write"`
}

Webhook struct {
Expand Down Expand Up @@ -88,7 +87,7 @@ func (c *Config) isGithubEnabled() bool {
}

func (c *Config) isSlackEnabled() bool {
return c.SlackClientID != "" && c.SlackClientSecret != "" && c.SlackSigningSecret != ""
return c.SlackClientID != "" && c.SlackClientSecret != ""
}

func (c *Config) hasTLS() bool {
Expand Down
1 change: 0 additions & 1 deletion cmd/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ func newChatConfig(c *Config) *server.ChatConfig {
Type: server.ChatTypeSlack,
ClientID: c.SlackClientID,
ClientSecret: c.SlackClientSecret,
Secret: c.SlackSigningSecret,
BotScopes: c.SlackBotScopes,
UserScopes: c.SlackUserScopes,
}
Expand Down
7 changes: 0 additions & 7 deletions docs/concepts/chatops.md

This file was deleted.

18 changes: 18 additions & 0 deletions docs/concepts/notification.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Notification

Gitploy notifies users when deployments and reviews are created or updated. Now, Gitploy supports browser notification and Slack.

## Browser

Gitploy provides the browser notification to alert events as default. Almost modern browsers provide [notification API](https://developer.mozilla.org/ko/docs/Web/API/notification), but unfortunately, some browsers are not supported. To avoid browser compatibility, you can replace it with Slack.

*Note that if the notification doesn't work even though your browser provides it, you should check the setting that it is enabled or not.*


## Slack

Slack is a popular messaging app for businesses globally. Gitploy supports Slack to notify events of deployments and reviews. You can figure out the Connect button on the settings page after integrating with Slack. Check [the documentation](../tasks/integration.md) for details.

Figure) Slack notification

![Slack Notification](../images/slack-notification.png)
Binary file modified docs/images/slack-bot-token-scopes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/images/slack-deploy.png
Binary file not shown.
Binary file removed docs/images/slack-interactivity.png
Binary file not shown.
Binary file removed docs/images/slack-new-command.png
Binary file not shown.
Binary file added docs/images/slack-notification.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 0 additions & 7 deletions docs/references/GITPLOY_SLACK_SIGNING_SECRET.md

This file was deleted.

1 change: 0 additions & 1 deletion docs/references/configurations.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ Index of server configuration settings:
* [GITPLOY_SERVER_PROTO](./GITPLOY_SERVER_PROTO.md)
* [GITPLOY_SLACK_CLIENT_ID](./GITPLOY_SLACK_CLIENT_ID.md)
* [GITPLOY_SLACK_CLIENT_SECRET](./GITPLOY_SLACK_CLIENT_SECRET.md)
* [GITPLOY_SLACK_SIGNING_SECRET](./GITPLOY_SLACK_SIGNING_SECRET.md)
* [GITPLOY_STORE_DRIVER](./GITPLOY_STORE_DRIVER.md)
* [GITPLOY_STORE_SOURCE](./GITPLOY_STORE_SOURCE.md)
* [GITPLOY_TLS_CERT](./GITPLOY_TLS_CERT.md)
Expand Down
34 changes: 5 additions & 29 deletions docs/tasks/integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,44 +33,20 @@ jobs:

## Slack

Slack integration provides Chatops (i.e. deploy, rollback) and notification alert for events.
Slack integration provides notifications for events.

### Step 1: Create App

Firstly, we have to create [Slack App](https://api.slack.com/apps). Let’s click the Create App button and fill out inputs.
Firstly, we have to create [Slack App](https://api.slack.com/apps). You should click the Create App button and fill out inputs.

### Step 2: Configure Permissions

After creating App let’s move to the *OAuth & Permissions* page. On this page, we have to set up *the redirect URLs* and *Bot Token scopes*. Firstly, let’s add a new redirect URL with the `GITPLOY_SERVER_PROTO://GITPLOY_SERVER_HOST/slack/signin` format; secondly, add `chat:write` and `commands` scopes into the Bot Token scopes.
After creating App, we move to the *OAuth & Permissions* page and set up *the redirect URLs* and *Bot Token scopes*on this page. Firstly, you should add a new redirect URL with the `GITPLOY_SERVER_PROTO://GITPLOY_SERVER_HOST/slack/signin` format; secondly, add `chat:write` scope into the Bot Token scopes.

Figure) Slack Bot Token Scopes

![Slack Bot Token Sceops](../images/slack-bot-token-scopes.png)

### Step 3: Create Slash Command

To use the slash command, we have to create a new command, `/gitploy`. Move to the *Slash Commands* page, and fill out the "Create New Command" form like the following:

* Command: `/gitploy`
* Request URL: `GITPLOY_SERVER_PROTO://GITPLOY_SERVER_HOST/slack/command`
* Short Description: `Gitploy command`
* Use Hint: `[deploy | rollback | help]`

Figure) Slack Create New Command

![Slack New Command](../images/slack-new-command.png)

### Step 4: Configure Interactivity

To enable the interactivity, we have to configure which URL interact with Slack. Move to the *Interactivity & Shortcuts* page, and fill out the "Request URL" with the `GITPLOY_SERVER_PROTO://GITPLOY_SERVER_HOST/slack/interact`

Figure) Slack Interactivity

![Slack Interactivity](../images/slack-interactivity.png)

### Step 5: Run Server With App Credentials

To enable Slack integration, you have to set up these environments when you run the server: `GITPLOY_SLACK_CLIENT_ID`, `GITPLOY_SLACK_CLIENT_SECRET`, and `GITPLOY_SLACK_SIGNING_SECRET`. You can get these credentials from *App Credentials* section of *Basic Information* page.

On settings page, you can find the button to connect with Slack. Now, you can run the slash command `/gitploy` in Slack.
### Step 3: Run Server With App Credentials

To enable Slack integration, you have to set up these environments when you run the server: `GITPLOY_SLACK_CLIENT_ID` and `GITPLOY_SLACK_CLIENT_SECRET`. You can get these credentials from *App Credentials* section of *Basic Information* page.
7 changes: 0 additions & 7 deletions internal/server/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ type (
Type ChatType
ClientID string
ClientSecret string
Secret string
BotScopes []string
UserScopes []string
}
Expand Down Expand Up @@ -219,10 +218,6 @@ func NewRouter(c *RouterConfig) *gin.Engine {
if isSlackEnabled(c) {
slackapi := r.Group("/slack")
{
m := s.NewSlackMiddleware(&s.SlackMiddlewareConfig{
Interactor: c.Interactor,
Secret: c.ChatConfig.Secret,
})
slack := s.NewSlack(&s.SlackConfig{
ServerHost: c.Host,
ServerProto: c.Proto,
Expand All @@ -232,8 +227,6 @@ func NewRouter(c *RouterConfig) *gin.Engine {
slackapi.GET("", slack.Index)
slackapi.GET("/signin", slack.Signin)
slackapi.GET("/signout", slack.Signout)
slackapi.POST("/interact", m.Verify(), m.ParseIntr(), m.SetChatUser(), slack.Interact)
slackapi.POST("/command", m.Verify(), m.ParseCmd(), m.SetChatUser(), slack.Cmd)
Comment on lines -235 to -236
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove /interact, /command API to delete Chatops

}
}

Expand Down
Loading