Skip to content

Commit

Permalink
Merge pull request #6 from insidieux/1.1.0
Browse files Browse the repository at this point in the history
Resolving issues and updates
  • Loading branch information
insidieux authored Aug 31, 2018
2 parents 90daf31 + 9386b7d commit 220648e
Show file tree
Hide file tree
Showing 7 changed files with 226 additions and 85 deletions.
11 changes: 4 additions & 7 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
*.md
Gopkg*
Makefile
LICENSE
/vendor
/idea
config.yaml
*

!.docker/docker-entrypoint
!slack-duty-bot
21 changes: 21 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
sudo: required

language: go

env:
global:
- SRC_DIR: /go/src/github.com/${TRAVIS_REPO_SLUG}
- DOCKER_TAG: ${TRAVIS_TAG}

services:
- docker

jobs:
include:
- stage: tests
script:
- make test SRC_DIR=${SRC_DIR}
- stage: push image
script:
- make push SRC_DIR=${SRC_DIR} DOCKER_NAMESPACE=${DOCKER_NAMESPACE} DOCKER_TAG=${DOCKER_TAG} DOCKER_USER=${DOCKER_USER} DOCKER_PASSWORD=${DOCKER_PASSWORD}
if: tag IS present
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
CHANGELOG
=========

1.1.0
-----
* Fixed issue [#4 - Kubernetes changed config map does not trigger fs event bug](/iqoption/slack-duty-bot/issues/2)
* Fixed issue [#5 - Bot gets triggered by channel topic modification bug](/iqoption/slack-duty-bot/issues/1)
* Add travis integration for automatic builds

1.0.0
-----
* Using Slack RTM
Expand Down
58 changes: 53 additions & 5 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

64 changes: 37 additions & 27 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,49 +1,59 @@
all: build

APP?=slack-duty-bot
# strict variables
APP:=slack-duty-bot
ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))

# build go binary variables
SRC_DIR?=$(shell echo '/go/$(shell echo ${ROOT_DIR} | awk -F'/go/' '{print $$2}')')
BUILD_OS?=linux
BUILD_ARCH?=amd64
DOCKER_IMAGE?=insidieux/${APP}

# docker build variables
DOCKER_NAMESPACE?=
DOCKER_IMAGE=${DOCKER_NAMESPACE}/${APP}
DOCKER_TAG?=1.0.0
DOCKER_USER?=user
DOCKER_PASSWORD?=password
DOCKER_USER?=
DOCKER_PASSWORD?=

# run variables
SDB_SLACK_TOKEN?=some-token
SDB_SLACK_KEYWORD?=keyword

clean:
rm -f ${APP}

dep-install:
go get -v -u github.com/golang/dep/cmd/dep

dep-ensure: dep-install
rm -rf vendor
dep ensure
rm -rf .vendor-new

test: dep-ensure
go test -v -race ./...

build: clean dep-ensure
env GOOS=${BUILD_OS} GOARCH=${BUILD_ARCH} CGO_ENABLED=0 go build -v -o ${APP}
dep-ensure:
docker run --rm \
-v ${ROOT_DIR}:${SRC_DIR} \
-w ${SRC_DIR} \
golang:1.10 \
bash -c "go get -v -u github.com/golang/dep/cmd/dep && dep ensure"

container: build
test: dep-ensure
docker run --rm \
-v ${ROOT_DIR}:${SRC_DIR} \
-w ${SRC_DIR} \
golang:1.10 \
go test -v -race ./...

build: dep-ensure
rm -f ${APP} || true
docker run --rm \
-v ${ROOT_DIR}:${SRC_DIR} \
-w ${SRC_DIR} \
golang:1.10 \
env GOOS=${BUILD_OS} GOARCH=${BUILD_ARCH} CGO_ENABLED=0 go build -o ${APP} -v main.go

image: build
docker rmi ${DOCKER_IMAGE}:${DOCKER_TAG} || true
docker build \
--build-arg APP=${APP} \
-f .docker/Dockerfile \
-t ${DOCKER_IMAGE}:${DOCKER_TAG} \
.

run: container
docker stop ${APP} || true && docker rm ${APP} || true
docker run \
--name ${APP} \
--rm \
-e SDB_SLACK_TOKEN=${SDB_SLACK_TOKEN} \
${DOCKER_IMAGE}:${DOCKER_TAG} \
--slack.keyword ${SDB_SLACK_KEYWORD}

push: container
push: image
docker login docker.io -u ${DOCKER_USER} -p ${DOCKER_PASSWORD}
docker push ${DOCKER_IMAGE}:${DOCKER_TAG}
25 changes: 23 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ docker run \
--slack.keyword keyword-1 \
--slack.keyword keyword-2
--slack.group.id your-group-id \
--slack.group.name your-group-name \
--slack.group.name your-group-name
```

### Build package
Expand Down Expand Up @@ -59,6 +59,7 @@ docker run \
Environment variables are prefixed with `SDB_` and **MUST** be uppercase with `_` delimiter

Available variables:
* `SDB_LOGGER_LEVEL`
* `SDB_SLACK_TOKEN`
* `SDB_SLACK_GROUP_ID`
* `SDB_SLACK_GROUP_NAME`
Expand All @@ -67,7 +68,8 @@ Available variables:
Every environment variable can be overwritten by startup flags

Available flags:
* `--config.path` - path to config.yaml file (default: . and $HOME/.slack-duty-bot)
* `--logger.level` - Log level (default: "info")
* `--config.path` - Path to config.yaml file (default: . and $HOME/.slack-duty-bot)
* `--slack.token` - Slack API client token
* `--slack.keyword` - Case insensitive keywords slice to search in message text, can be set multiple times (default: [])
* `--slack.group.name` - Slack user group name, to mention in channel if duty list is empty
Expand Down Expand Up @@ -175,6 +177,25 @@ After that you can change configuration with `kubect` or edit config map directl
kubectl apply -f $(pwd)/.kubernetes/deploy.yaml --namespace slack-duty-bot
```

## Contributing

### Travis-CI and tests
To enable tests for your fork repository you **MUST**:

* Create your project in [TravisCI](http://travis-ci.com) for your fork repository
* Add environment variables to Travis-CI project:
* `DOCKER_NAMESPACE`
* `DOCKER_USER`
* `DOCKER_PASSWORD`

Travis-CI will run test on every push for every ref and build docker image and push to [docker hub](http://hub.docker.io) *ONLY FOR TAGS*

## Changelog
[Changelog for project](CHANGELOG.md)

## Roadmap
[Roadmap for project](ROADMAP.md)

## Authors
* [Konstantin Perminov](https://github.com/SpiLLeR)
* [Ageev Pavel](https://github.com/insidieux)
Loading

0 comments on commit 220648e

Please sign in to comment.