https://github.com/nmasse-itix/tekton-pipeline-slack-bot
This project is a slack bot that waits for approval on a specified channel and exits upon approval. It is used to let Product Managers approve a release into production using Tekton Pipeline.
https://github.com/nmasse-itix/tekton-pipeline-slack-bot
slack-bot slackbot tekton-pipelines
Last synced: 6 months ago
JSON representation
This project is a slack bot that waits for approval on a specified channel and exits upon approval. It is used to let Product Managers approve a release into production using Tekton Pipeline.
- Host: GitHub
- URL: https://github.com/nmasse-itix/tekton-pipeline-slack-bot
- Owner: nmasse-itix
- Created: 2023-05-31T13:46:51.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-05-31T16:23:45.000Z (over 2 years ago)
- Last Synced: 2025-02-12T11:16:22.445Z (8 months ago)
- Topics: slack-bot, slackbot, tekton-pipelines
- Language: Java
- Homepage:
- Size: 18.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Tekton Pipeline - Approval Slack Bot
This project is a slack bot that waits for approval on a specified channel and exits upon approval.
It is used to let Product Managers approve a release into production using Tekton Pipeline.It uses Quarkus, the Supersonic Subatomic Java Framework.
If you want to learn more about Quarkus, please visit its website: https://quarkus.io/ .## Pre-requisites
* Create a Slack application on [api.slack.com/apps](https://api.slack.com/apps).
* Create an **App-Level Token** with the `connections:write` scope.
* Enable **Socket Mode**.
* In **OAuth & Permissions**, enable the `app_mentions:read`, `channels:read`,`chat:write` and `commands` scopes.
* In the **Slash Commands**, add the `/lgtm` command.
* **Install App** to your Workspace## Usage
* Invite the bot to your channel
* Start the bot with the **SLACK_CHANNEL** and **TEKTON_PIPELINE_ID** environment variables
* Wait for the bot to post the message on the channel
* Send the "/lgtm 1234" command (where 1234 is the id of the tekton pipeline to approve)
* The application exits with code 0## Running the application in dev mode
Install Java 11:
```sh
sudo dnf install java-11-openjdk-devel
sudo alternatives --config java
sudo alternatives --config javac
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-11.0.19.0.7-1.fc37.x86_64
```You can run your application in dev mode that enables live coding using:
```shell script
export SLACK_CHANNEL="#mad-roadshow-france-2023"
export TEKTON_PIPELINE_ID="1234"
export SLACK_BOT_TOKEN="xoxb-...."
export SLACK_APP_TOKEN="xapp-...."
./mvnw compile quarkus:dev
```## Packaging and running the application
The application can be packaged using:
```shell script
./mvnw package
podman build -f src/main/docker/Dockerfile.jvm -t quay.io/madroadshowfrance2023/tekton-pipeline-slack-bot:latest .
podman login quay.io
podman push quay.io/madroadshowfrance2023/tekton-pipeline-slack-bot:latest
```## Usage in Tekton Pipelines
```sh
kubectl create secret generic tekton-tokens --from-literal=bot-token=xoxb-.... --from-literal=app-token=xapp-....
kubectl apply -f src/main/kubernetes/pipeline.yaml
kubectl create -f src/main/kubernetes/pipelinerun.yaml
```## Related Guides
* [Getting started with Bolt (Socket Mode)](https://slack.dev/java-slack-sdk/guides/getting-started-with-bolt-socket-mode)
* [Permission Scopes](https://api.slack.com/scopes)
* [Supported Web Frameworks](https://slack.dev/java-slack-sdk/guides/supported-web-frameworks)