Skip to content

Commit

Permalink
Update dependencies and python version and switch to ghcr
Browse files Browse the repository at this point in the history
  • Loading branch information
swoehrl-mw committed Jan 25, 2024
1 parent cb31f9b commit 7e9928a
Show file tree
Hide file tree
Showing 10 changed files with 75 additions and 57 deletions.
28 changes: 17 additions & 11 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Publish Docker image
name: Publish new release
on:
push:
tags:
Expand All @@ -10,22 +10,30 @@ jobs:
steps:

- name: Check out the repo
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Push to Docker Hub
uses: docker/build-push-action@v1
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: maibornwolff/opsbot
tag_with_ref: true
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push image to GitHub Container Registry
env:
GITHUB_REF: ${{ github.ref }}
run: |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/opsbot
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
TAG=${GITHUB_REF//refs\/tags\/v}
docker build . -t $IMAGE_ID:$TAG --push
- name: Prepare helm chart
env:
GITHUB_REF: ${{ github.ref }}
run: |
sed -i 's/0.0.1/'"${GITHUB_REF//refs\/tags\/v}"'/' deploy/helm/opsbot/Chart.yaml
sed -i 's/v0.0.1/'"${GITHUB_REF//refs\/tags\/}"'/' deploy/helm/opsbot/values.yaml
sed -i 's/0.0.1/'"${GITHUB_REF//refs\/tags\/v}"'/' deploy/helm/opsbot/values.yaml
- name: Publish helm chart
uses: stefanprodan/helm-gh-pages@master
Expand All @@ -34,7 +42,6 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -43,4 +50,3 @@ jobs:
release_name: Release ${{ github.ref }}
draft: false
prerelease: false

2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.7-slim
FROM python:3.11-slim

COPY requirements.txt /requirements.txt
RUN pip install -r /requirements.txt
Expand Down
59 changes: 34 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,26 @@ The Bot in Teams has to be configured with the public URL of the backend service
After you have installed both the Bot in MS Teams, and the backend Service you need to initialize the Opsbot.
This will set the Channel you issued the init command in as the default channel for the Opsbot:

@Opsbot init

```plain
@Opsbot init
```

You can then ask the Opsbot for a complete list of all possible commands:

@Opsbot help
```plain
@Opsbot help
```

### Teams Bot

To configure a bot in Microsoft Teams you use the Teams app "App Studio".
There you can create the configuration (A json manifest file) for the Bot and install it into your teams channel.
In `deploy/ms_teams` you find an example of such a manifest file. You can import and modify the provided one or create your own.
In both cases you will need to create a new Bot id and password in App Studio and set those in your Backend configuration.

### Backend

The backend service is provided as a dockerfile which is available at [Dockerhub](https://hub.docker.com/r/maibornwolff/opsbot).
The backend service is provided as a docker image which is available in the Github Container Registry for this repo.
You can use this one or build your own from this repository. In any case you have to deploy the service somewhere publicly available.

#### Kubernetes
Expand All @@ -44,8 +48,10 @@ For kubernetes deployment a helm template is included in the project under `depl

You can install this chart with

$ helm repo add maibornwolff-opsbot https://MaibornWolff.github.io/opsbot
$ helm install my-release maibornwolff-opsbot/opsbot --values my-values.yaml
```bash
helm repo add maibornwolff-opsbot https://MaibornWolff.github.io/opsbot
helm install my-release maibornwolff-opsbot/opsbot --values my-values.yaml
```

To further simplify the deployment even more there is also a predefined helmfile (deploy/helmfile/helmfile.yaml) available.
You can configure the deployment of the backend service and also provide the Opsbot configuration in one file.
Expand All @@ -65,9 +71,9 @@ These plugins are currently included in OpsBot:
| Plugin | Description |
|---|---|
| Operations | Team member can be registered with this plugin. Every day the plugin chooses an operations responsible for the day and announces him or her in the Chat. |
| Sayings | A plugin that reacts to unknown commands with an insult. |
| Jira | This plugin can check Jira for Defect tickets and it can create subtasks for an existing ticket. |
| Alerts | Checks an alertmanager for active alerts. |
| Sayings | A plugin that reacts to unknown commands with an insult. |
| Jira | This plugin can check Jira for Defect tickets and it can create subtasks for an existing ticket. |
| Alerts | Checks an alertmanager for active alerts. |

This is an overview of all possible configuration parameters:

Expand Down Expand Up @@ -152,7 +158,7 @@ actions: # Configuration for the different plugins
Below you find a list of all commands, the Opsbot understands.
All commands are issued by mentioning the Opsbot either in a channel or via direct message. (@Opsbot \<command\>)
##### Global commands:
#### Global commands
| Command | Description |
|---------|-------------|
Expand All @@ -161,7 +167,7 @@ All commands are issued by mentioning the Opsbot either in a channel or via dire
| unregister channel XX | Remove the channel assignment for type XX |
| help | Print out the help |
##### Operations plugin:
#### Operations plugin
| Command | Description |
|---------|-------------|
Expand All @@ -172,7 +178,7 @@ All commands are issued by mentioning the Opsbot either in a channel or via dire
| morgen <br/> tomorrow | Prints out who is the responsible tomorrow |
| 'Urlaub am dd.mm.yyyy' [@user] <br/> 'Urlaub von dd.mm.yyyy bis dd.mm.yyyy' [@user] <br/> 'Urlaub dd.mm.yyyy - dd.mm.yyyy' [@user] | Add your vacation or those of another mentioned person |
##### Jira plugin:
#### Jira plugin
| Command | Description |
|---------|-------------|
Expand All @@ -181,25 +187,28 @@ All commands are issued by mentioning the Opsbot either in a channel or via dire
| fix XXX-XXXX | Solves the issue XXX-XXXX |
| defects | Lists current defects |
### Channels
Opsbot supports multiple Channels. The default is always the one the `init` command was issued in.
You can then tell Opsbot to send certain types of messages to another channel by sending this command:

@Opsbot channel register defects

```plain
@Opsbot channel register defects
```

The channel type 'defects' that is used for this example is configured in the [Jira plugin](opsbot/plugins/actions/jira.py) when it sends out scheduled messages.
If there is no channel set for a type, the default one is used. There is also a deregister command to remove the association:

@Opsbot defects deregister channel
```plain
@Opsbot defects deregister channel
```

#### Available channels

| Plugin | Channel type |
|---|---|
| Jira | defects |
| Alerts | alerts |

| Alerts | alerts |

## Local development

Expand All @@ -212,17 +221,17 @@ Then you only need to create the `opsbot_config.yaml` file, and you can run Opsb

To simplify the local development of the bot there is also a small CLI tool with which you can talk to the bot while it is running on your local machine.

The CLI sends messages to the Opsbot at `localhost:5000`. In these messages the URL the Bot is going to reply to is set to `localhost:1234`.
The CLI sends messages to the Opsbot at `localhost:5000`. In these messages the URL the Bot is going to reply to is set to `localhost:1234`.
To receive those the CLI tool spins up a simple Flask server that listens on that port and echoes the responses of Opsbot.

The CLI can be started with `./run_cli.sh` and understands the following commands:

* start: Start of restart the flask server
* stop: Stop the flask server
* send "<message>": Send a message to opsbot
* quit/exit: Exit the CLI
* `start`: Start of restart the flask server
* `stop`: Stop the flask server
* `send "<message>"`: Send a message to opsbot
* `quit`/`exit`: Exit the CLI

## Custom plugins
## Custom plugins

Opsbot can be extended with new features by adding custom plugins. A custom plugin must extend the abstract `ActionPlugin` or `PersistencePlugin` class and implement their required methods.
In the configuration `additional_plugin_dir` then needs to be set to the directory containing the custom plugin.
Expand Down
9 changes: 6 additions & 3 deletions deploy/helm/opsbot/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
apiVersion: v1
appVersion: "1.0"
description: A Microsoft Team bot that helps organize operational tasks
apiVersion: v2
name: opsbot
description: A Microsoft Teams bot that helps organize operational tasks
type: application
version: 0.0.1
appVersion: "0.0.1"
sources:
- https://github.com/MaibornWolff/opsbot
2 changes: 1 addition & 1 deletion deploy/helm/opsbot/templates/pvc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ spec:
{{- if .Values.pvc.volumeName }}
volumeName: {{ .Values.pvc.volumeName }}
{{- end }}
{{ end }}
{{ end }}
2 changes: 1 addition & 1 deletion deploy/helm/opsbot/templates/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ rules:
- apiGroups: [""]
resources: ["configmaps"]
verbs: ["get", "create", "patch", "update", "watch"]
{{- end -}}
{{- end -}}
2 changes: 1 addition & 1 deletion deploy/helm/opsbot/templates/rolebinding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ roleRef:
kind: Role
name: {{ include "opsbot.fullname" . }}
apiGroup: rbac.authorization.k8s.io
{{- end -}}
{{- end -}}
2 changes: 1 addition & 1 deletion deploy/helm/opsbot/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ spec:
app.kubernetes.io/name: {{ include "opsbot.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- if .Values.podLabels }}
{{- toYaml .Values.podLabels | nindent 4 }}
{{- toYaml .Values.podLabels | nindent 4 }}
{{- end }}
4 changes: 2 additions & 2 deletions deploy/helm/opsbot/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
replicaCount: 1

image:
repository: maibornwolff/opsbot
tag: v0.0.1
repository: ghcr.io/maibornwolff/opsbot
tag: 0.0.1
pullPolicy: IfNotPresent

nameOverride: ""
Expand Down
22 changes: 11 additions & 11 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
Flask==2.1.0
requests==2.25.1
botbuilder-core==4.14.0
botbuilder-schema==4.14.0
botframework-connector==4.14.0
APScheduler==3.6.3
kubernetes==18.20.0
holidays==0.10.3
beautifulsoup4==4.9.3
Flask==3.0.1
requests==2.31.0
botbuilder-core==4.14.7
botbuilder-schema==4.14.7
botframework-connector==4.14.7
APScheduler==3.10.4
kubernetes==29.0.0
holidays==0.41
beautifulsoup4==4.12.3
oyaml==1.0
click-shell[readline]==2.1
pytz==2020.1
aiohttp==3.7.4.post0
pytz==2023.3.post1
aiohttp==3.9.1

0 comments on commit 7e9928a

Please sign in to comment.