diff --git a/.icons/slack.svg b/.icons/slack.svg new file mode 100644 index 0000000..fb55f72 --- /dev/null +++ b/.icons/slack.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/slackme/README.md b/slackme/README.md new file mode 100644 index 0000000..b301ed7 --- /dev/null +++ b/slackme/README.md @@ -0,0 +1,63 @@ +--- +display_name: Slack Me +description: Send a Slack message when a command finishes inside a workspace! +icon: ../.icons/slack.svg +maintainer_github: coder +verified: true +tags: [helper] +--- + +# Slack Me + +Add the `slackme` command to your workspace that DMs you on Slack when your command finishes running. + +```bash +$ slackme npm run long-build +``` + +## Setup + +1. Navigate to [Create a Slack App](https://api.slack.com/apps?new_app=1) and select "From an app manifest". Select a workspace and paste in the following manifest, adjusting the redirect URL to your Coder deployment: + + ```json + { + "display_information": { + "name": "Command Notify", + "description": "Notify developers when commands finish running inside Coder!", + "background_color": "#1b1b1c" + }, + "features": { + "bot_user": { + "display_name": "Command Notify" + } + }, + "oauth_config": { + "redirect_urls": [ + "https:///external-auth/slack/callback" + ], + "scopes": { + "bot": ["chat:write"] + } + } + } + ``` + +2. In the "Basic Information" tab on the left after creating your app, scroll down to the "App Credentials" section. Set the following environment variables in your Coder deployment: + + ```env + CODER_EXTERNAL_AUTH_1_TYPE=slack + CODER_EXTERNAL_AUTH_1_SCOPES="chat:write" + CODER_EXTERNAL_AUTH_1_DISPLAY_NAME="Slack Me" + CODER_EXTERNAL_AUTH_1_CLIENT_ID=" + CODER_EXTERNAL_AUTH_1_CLIENT_SECRET="" + ``` + +3. Restart your Coder deployment. Any Template can now import the Slack Me module, and `slackme` will be available on the `$PATH`: + + ```hcl + module "slackme" { + source = "https://registry.coder.com/modules/slackme" + agent_id = coder_agent.example.id + auth_provider_id = "slack" + } + ``` diff --git a/slackme/main.tf b/slackme/main.tf index a4909cf..76e9b09 100644 --- a/slackme/main.tf +++ b/slackme/main.tf @@ -14,9 +14,9 @@ variable "agent_id" { description = "The ID of a Coder agent." } -variable "external_provider_id" { +variable "auth_provider_id" { type = string - description = "The ID of an external provider." + description = "The ID of an external auth provider." } resource "coder_script" "install_slackme" { @@ -28,7 +28,7 @@ resource "coder_script" "install_slackme" { CODER_DIR=$(dirname $(which coder)) cat > $CODER_DIR/slackme <