Skip to content

Commit

Permalink
support multi-channel live standup configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
chrispruitt committed May 6, 2022
1 parent 458bb61 commit aa5d070
Show file tree
Hide file tree
Showing 603 changed files with 1,037 additions and 167,868 deletions.
5 changes: 5 additions & 0 deletions .env-example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
DEBUG=true
SLACK_BOT_TOKEN=
SLACK_APP_TOKEN=
S3_BRAIN_BUCKET=
S3_BRAIN_KEY=brain.json
6 changes: 2 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
standup-bot
.vscode
.env.sh
dist
.env
dist
3 changes: 1 addition & 2 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,13 @@ dockers:
- "justmiles/standup-bot:v{{ .Major }}"

skip_push: false
use_buildx: false
use: buildx
extra_files:
- go.mod
- go.sum
- LICENSE
- main.go
- lib
- vendor

archives:
- replacements:
Expand Down
20 changes: 9 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
FROM golang:1.12-stretch as builder
FROM golang:1.16-alpine

COPY . /app
WORKDIR /app
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo .
RUN md5sum standup-bot

# Create image from scratch
FROM scratch
COPY lib lib
COPY go.mod go.mod
COPY go.sum go.sum
COPY main.go main.go
COPY LICENSE LICENSE

COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=builder /app/standup-bot /standup-bot
COPY --from=builder /tmp /tmp
RUN go mod download

ENV AWS_DEFAULT_REGION us-east-1
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -o /standup-bot

ENTRYPOINT ["/standup-bot"]
CMD [ "/standup-bot" ]
38 changes: 14 additions & 24 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,28 +1,18 @@
VERSION=$$(git describe --tags $$(git rev-list --tags --max-count=1))

build:
docker build . -t standup-bot

run:
docker run -it -e SSH_AUTH -e SLACK_TOKEN standup-bot
go run main.go

gen:
go get github.com/abice/go-enum
go-enum --file plugins/terraform/types.go

dev:
# install justrun with
# go get github.com/jmhodges/justrun

# Grab env configs
# eval "$(get-ssm-params -path /ops/standup-bot -output shell)"
justrun -c 'go run main.go' -delay 10000ms main.go lib/plugins/** lib/slack/*
build:
docker build -t standup-bot .

push:
# Push latest
docker tag standup-bot:latest 965579072529.dkr.ecr.us-east-1.amazonaws.com/standup-bot:latest
docker push 965579072529.dkr.ecr.us-east-1.amazonaws.com/standup-bot:latest
docker-run:
docker run \
-it \
--env-file .env \
-e AWS_REGION \
-e AWS_ACCESS_KEY_ID \
-e AWS_SECRET_ACCESS_KEY \
-e AWS_SESSION_TOKEN \
-t standup-bot

# Push version
docker tag standup-bot:latest 965579072529.dkr.ecr.us-east-1.amazonaws.com/standup-bot:$(VERSION)
docker push 965579072529.dkr.ecr.us-east-1.amazonaws.com/standup-bot:$(VERSION)
release:
goreleaser --rm-dist
64 changes: 45 additions & 19 deletions README.MD
Original file line number Diff line number Diff line change
@@ -1,26 +1,52 @@
# standup-bot
**Description**

## Getting started
This is a simple standup bot for slack.

- [install go](https://golang.org/doc/install)
- export any required environment variables
- run with `make dev`
**Setup**

## Environment Configs
1. Create standup bot with `app-manifest.yaml` file provided in the root of this directory
1. Get bot and bot user tokens and set environment variables defined in `lib/config/main.go`
1. Set up s3 bucket and provide AWS Creds if you would like standup settings to persists between restarts

If you set `SSM_PATH` config values are pull from SSM. Values in SSM are the same as below.
**Docker**

- `SSM_PATH` - Pull configs from SSM using this SSM path
- `SLACK_TOKEN` - API token used to auth against Slack as a bot user
- `OAUTH_SLACK_TOKEN` - API token used to auth against Slack using oauth. Required for non-bot API scope
- `SLACK_GROUP` - Name of Slack group containing participating users
- `SLACK_CHANNEL` - Channel ID to post standup notes in
- `CRON_SOLICIT_STANDUP` - cron expression in UTC to solicit for standup notes. example, "0 0 13 * * mon-fri", // 8AM central
- `CRON_SHARE_STANDUP` - cron expression in UTC to share standup notes to the main channel. example, "0 0 13 * * mon-fri", // 8AM central
- `STANDUP_MESSAGE` - optionally customize the message sent to users when soliciting for standup notes
- `SHAME_PARTICIPANTS` - if set to "true" post a message when user doesn't particiapte in the standup
```bash
# quickstart
docker run \
-e SLACK_BOT_TOKEN=xoxb-blahblah \
-e SLACK_APP_TOKEN=xapp-blahblah \
-t justmiles/standup-bot

## Roadmap
# with persistant brain
docker run \
-e SLACK_BOT_TOKEN=xoxb-blahblah \
-e SLACK_APP_TOKEN=xapp-blahblah \
-e S3_BRAIN_BUCKET=some_s3_bucket \
-e S3_BRAIN_KEY=brain.json \
-e AWS_REGION \
-e AWS_ACCESS_KEY_ID \
-e AWS_SECRET_ACCESS_KEY \
-e AWS_SESSION_TOKEN \
-t justmiles/standup-bot
```

- [x] instead of sourcing partificpans by Slack Group, just message everyone in the `SLACK_CHANNEL`
- [x] add property `STANDUP_MESSAGE` to customize the message sent to users when solociting standup notes
**Configure your bot**

In slack just type `/standup`

**Test your bot**

In a channel type the below commands - this will create a mock standup with you as the sole participant.
`/standup solicit`
`/standup share`

**Users in multiple standups Scenarios**

If User recieves a standup solicitation from multiple channel configurations at the same time, then:
- If User replies as normal, then both standups will receive the same notes.
- If user replies in thread, then only the thread response will be used for the standup notes.

**Roadmap**

- Provide terraform module for quick setup in fargate
- Update readme with a "how to"
53 changes: 53 additions & 0 deletions app-manifest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
_metadata:
major_version: 1
minor_version: 1
display_information:
name: standup-bot
description: An attempt at async standups,
background_color: "#2e2e2e"
features:
app_home:
home_tab_enabled: false
messages_tab_enabled: true
messages_tab_read_only_enabled: false
bot_user:
display_name: Standup Bot
always_online: true
slash_commands:
- command: /standup
description: Set standup settings for a given channel.
should_escape: false
oauth_config:
scopes:
user:
- links:write
bot:
- app_mentions:read
- channels:history
- im:history
- users:read
- incoming-webhook
- channels:read
- im:read
- team:read
- usergroups:read
- users.profile:read
- chat:write
- chat:write.public
- groups:write
- groups:read
- im:write
- groups:history
- commands
settings:
event_subscriptions:
bot_events:
- app_mention
- message.im
- message.channels
- message.groups
interactivity:
is_enabled: true
org_deploy_enabled: false
socket_mode_enabled: true
token_rotation_enabled: false
19 changes: 6 additions & 13 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
module github.com/justmiles/standup-bot

replace github.com/justmiles/standup-bot/lib/plugins => ./lib/plugins
go 1.16

replace github.com/justmiles/standup-bot/lib/slack => ./lib/slack

replace github.com/justmiles/standup-bot/lib/configs => ./lib/configs

replace github.com/justmiles/standup-bot/lib/standup => ./lib/standup

go 1.15
replace github.com/justmiles/standup-bot/lib/standup => ./standup

require (
github.com/aws/aws-sdk-go v1.37.21
github.com/dustin/go-humanize v1.0.0
github.com/go-chat-bot/bot v0.0.0-20201004141219-763f9eeac7d5
github.com/go-chat-bot/plugins v0.0.0-20201024114236-00ff43fcf77f
github.com/aws/aws-sdk-go v1.41.4
github.com/chrispruitt/go-slackbot v0.3.2
github.com/lucasb-eyer/go-colorful v1.2.0
github.com/slack-go/slack v0.8.1
github.com/sirupsen/logrus v1.8.1
github.com/slack-go/slack v0.9.4
)
Loading

0 comments on commit aa5d070

Please sign in to comment.