-
Notifications
You must be signed in to change notification settings - Fork 12
Integrate Slack
Integration with Slack allows for interactive deployment from the channel. To set up a Slack integration, you need to have permission to create a Slack app.
-
Create a new Slack app in app manifest mode. Register the following manifest file and click [Next]. Rewrite
YOUR_APP
andYOUR_HOST
according to your environment.{ "display_information":{ "name":"{YOUR_APP}-genova", "description":"genova", "background_color":"#000000" }, "features":{ "bot_user":{ "display_name":"{YOUR_APP}-genova", "always_online":true } }, "oauth_config":{ "redirect_urls":[ "https://{YOUR_HOST}/api/v2/slack/auth" ], "scopes":{ "bot":[ "app_mentions:read", "chat:write", "users:read" ] } }, "settings":{ "event_subscriptions":{ "request_url":"https://{YOUR_HOST}/api/v2/slack/event", "bot_events":[ "app_mention" ] }, "interactivity":{ "is_enabled":true, "request_url":"https://{YOUR_HOST}/api/v2/slack/post" }, "org_deploy_enabled":false, "socket_mode_enabled":false, "token_rotation_enabled":false } }
-
When a confirmation window opens, click on [Create].
-
Click on [OAuth & Permissions] from the sidebar.
-
With [Basic Information] open in the sidebar, click the [Install to Workspace] button in the [Install your app] section.
-
For subsequent setup instructions, see Step 3 of the From Scratch Setup Instructions.
- Skip Step 6 as it is not necessary.
-
Create a new Slack app in scratch mode.
-
Change the settings of the application as follows.
- [Features] - [Interactivity & Shortcuts]
- Turn on the [Interactivity] toggle.
- Click on [Save changes].
- [Features] - [OAuth & Permissions]
-
Redirect URLs
- Click on [Add New Redirect URL].
- Click on [Add] - [Save URLs].
- Click on [Add New Redirect URL].
- [Scopes]
- [Bot Token Scopes]
- Click on [Add an OAuth Scope] to add [app_mentions:read], [chat:write], [users:read].
- [Bot Token Scopes]
-
Redirect URLs
- [Features] - [App Home] (Optional)
- [Your App’s Presence in Slack]
- Turn on the [Always Show My Bot as Online] toggle.
- [Your App’s Presence in Slack]
- Settings - Install App
- Click on [Install to Workspace].
- When asked for permission to access your workspace, press [Allow].
- [Features] - [Interactivity & Shortcuts]
-
When you start Slack, the app you just installed will be added to the side panel.
- Open the channel you want to add the bot to and enter
/invite
in the message field. OpenAdd apps to this channel
from the menu that appears. - When the modal for the app you want to add opens, press the [Add] for the app you just created.
- Open the channel you want to add the bot to and enter
-
Set the Slack app credentials in the genova configuration file
config/settings.local.yml
. Credential information can be checked from [Basic information] in the Slack app sidebar.console: url: url: https://{CONSOLE_URL}/ github: account: 'xxx' repositories: # Repository name to be deployed. For example, for https://github.com/xxx/your_app, specify `your_app`. - name: 'xxx' slack: # Client ID client_id: 'xxx' # Client Secret client_secret: 'xxx' # Signing Secret signing_secret: 'xxx' # Verification Token verification_token: 'xxx' # Specify the [Bot User OAuth Token] that will be displayed on the [OAuth & Permissions] page. api_token: 'xxx' # Parameters starting with `C` included in Slack channel URL channel_id: 'xxx'
-
Restart genova for the configuration to take effect.
$ docker compose stop && docker compose up -d
-
Open the Slack app screen again and make the following settings.
- [Settings] - [Manage Distribution]
- [Share Your App with Your Workspace]
- Click on [Add to Slack].
- JSON with
team_id
will be returned if the integration with Slack is successful.
- [Share Your App with Your Workspace]
- [Features] - [Event Subscriptions]
- Turn on the [Enable Events] toggle.
-
Requests URL
:https://{CONSOLE_URL}/api/v2/slack/event
- Press [Subscribe to bot events].
- Click on [Add Bot User Event] and add [app_mention].
- Click on [Save changes].
- [Settings] - [Manage Distribution]
-
The setup is now complete. Open Slack and enter
@{BOT} version
in the channel where your bot is running. If the version message is displayed, it is successful.
Permissions can be used to limit the members that can be deployed from a channel. If a member who does not own the permission tries to deploy, an insufficient access permission error will occur.
# config/settings.local.yml
slack:
permissions:
# Target of restrictions. You can specify `repository` or `cluster` or 'workflow'.
- policy: cluster
# You can specify full match or partial match for string (e.g. `production-*`, `*`).
# If only asterisks are specified, they must be enclosed in single quotes.
# * When `policy` is a `repository`: Target repository name.
# * When `policy` is a `cluster`: Target cluster name.
# * When `policy` is a `workflow`: Target workflow name.
resources:
- production-api
# List of allowed users. User can be specified by Slack user ID.
allow_users:
- U04F0AWUE
- If you add the
permission
parameter, the default behavior is to refuse to deploy all members.