Skip to content

Commit f09c731

Browse files
committed
Update README files to clarify GitLab Bot setup and usage instructions
1 parent 9980912 commit f09c731

File tree

2 files changed

+95
-10
lines changed

2 files changed

+95
-10
lines changed

README.md

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
![Docker Image Version (latest by date)](https://img.shields.io/docker/v/coolbeevip/gitlab-bot/latest)
44
[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
55

6-
This is a GitLab(13.2+) bot that utilizes [webhooks](https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html) to automate certain tasks:
6+
This is a GitLab(13.2+) bot that utilizes [webhooks](https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html) to automate certain tasks
7+
8+
## Features
79

810
#### Verify if the submitters email domain during Merge requests.
911

@@ -54,19 +56,60 @@ This is a GitLab(13.2+) bot that utilizes [webhooks](https://docs.gitlab.com/ee/
5456

5557
## How to use
5658

57-
Starting a Gitlab Bot instance is simple:
59+
In order to start the GitLab Bot, you'll need to prepare three environment variables: `BOT_GITLAB_USERNAME`, `BOT_GITLAB_URL`, and `BOT_GITLAB_TOKEN`.
60+
61+
- **BOT_GITLAB_USERNAME**: This is your GitLab username, which identifies your account on GitLab. You can find it on your GitLab profile page. **(It is recommended that you create a new user for this, such as `review-bot`.)**
62+
63+
- **BOT_GITLAB_URL**: This is the URL of your GitLab instance. If you're using GitLab.com, the URL will be `https://gitlab.com`. If you're running a self-hosted GitLab instance, use the URL configured for it (e.g., `http://your-gitlab-instance.com`).
64+
65+
- **BOT_GITLAB_TOKEN**: This is `BOT_GITLAB_USERNAME` access token that grants the bot permission to interact with your GitLab instance. You can generate a personal access token by following these steps:
66+
1. Log in to your GitLab account.
67+
2. Go to your user settings (click on your profile picture at the top right, then select Settings).
68+
3. Navigate to `Access Tokens`.
69+
4. Generate the token and make sure to save it securely, as it will be visible only once.
70+
71+
#### Starting a Gitlab Bot:
5872

5973
> In Docker version 19, utilizing the "--security-opt seccomp:unconfined" option when running a container with a preconfigured seccomp profile can disable the seccomp filter and allow processes to execute any system call.
6074
6175
```shell
6276
docker run --rm \
63-
-e BOT_GITLAB_USERNAME="Your Gitlab Username" \
64-
-e BOT_GITLAB_URL="Your Gitlab URL" \
65-
-e BOT_GITLAB_TOKEN="Your Gitlab Access Token" \
77+
-e BOT_GITLAB_USERNAME="review-bot" \
78+
-e BOT_GITLAB_URL="http://your-gitlab-instance.com" \
79+
-e BOT_GITLAB_TOKEN="<User review-bot's access token> \
6680
-p 9998:9998 \
6781
coolbeevip/gitlab-bot
6882
```
6983
84+
#### Setting Up a Webhook in GitLab
85+
86+
To enable the GitLab Bot to respond to events, you need to configure a Webhook in your GitLab project. Follow these steps:
87+
88+
1. **Open Project View**:
89+
- Log in to GitLab.
90+
- In the dashboard, find and click on your project.
91+
92+
2. **Enter Webhook Settings**:
93+
- In the left sidebar menu, navigate to `Settings` -> `Webhooks`.
94+
95+
3. **Add a New Webhook**:
96+
- Click on the `Add new webhook` button.
97+
98+
4. **Fill in the Information**:
99+
- In the form that appears, fill in the following details:
100+
- **URL**: Enter the address that will receive the Webhook requests, for example, `http://localhost:9998`.
101+
- **Trigger**:
102+
- Select the events you want to trigger the Webhook, such as:
103+
- `Comments` (comment events)
104+
- `Issues events` (issue events)
105+
- `Merge request events` (merge request events)
106+
107+
5. **Save the Webhook**:
108+
- Click on the `Add webhook` button to save your configuration.
109+
110+
6. **Test the Webhook (Optional)**:
111+
- To confirm if the Webhook is set up correctly, locate the newly added Webhook in the Webhooks list and use the `Test` button to send a test request.
112+
70113
## Environment Variables
71114
72115
**`BOT_GITLAB_USERNAME` / `BOT_GITLAB_URL` / `BOT_GITLAB_TOKEN`**

README_ZH.md

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
![Docker镜像版本(最新)](https://img.shields.io/docker/v/coolbeevip/gitlab-bot/latest)
44
[![许可证](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
55

6-
这是一个适用于 GitLab(13.2+) 的机器人,利用 [webhooks](https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html) 来自动化某些任务:
6+
这是一个适用于 GitLab(13.2+) 的机器人,利用 [webhooks](https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html) 来自动化一些任务
7+
8+
## 功能
79

810
#### 在合并请求中验证提交者的电子邮件域名。
911

@@ -54,19 +56,59 @@
5456

5557
## 如何使用
5658

57-
启动 Gitlab Bot 实例非常简单:
59+
为了启动 GitLab Bot,您需要准备三个环境变量:`BOT_GITLAB_USERNAME``BOT_GITLAB_URL``BOT_GITLAB_TOKEN`
60+
61+
- **BOT_GITLAB_USERNAME**:这是您的 GitLab 用户名,用于识别您在 GitLab 上的账户。您可以在您的 GitLab 个人资料页面找到它。**(建议您为此创建一个新的用户,例如 `review-bot`)**
62+
63+
- **BOT_GITLAB_URL**:这是您的 GitLab 实例的 URL。如果您使用的是 GitLab.com,则 URL 将是 `https://gitlab.com`。如果您正在运行自托管的 GitLab 实例,请使用为其配置的 URL(例如 `http://your-gitlab-instance.com`)。
64+
65+
- **BOT_GITLAB_TOKEN**:这是 `BOT_GITLAB_USERNAME` 的访问令牌,授予机器人与您的 GitLab 实例交互的权限。您可以通过以下步骤生成个人访问令牌:
66+
1. 登录到您的 GitLab 账户。
67+
2. 转到您的用户设置(点击右上角的个人资料图片,然后选择设置)。
68+
3. 导航到 `访问令牌`
69+
4. 生成令牌并确保安全保存,因为它只会显示一次。
70+
71+
#### 启动 Gitlab Bot
5872

5973
> 在 Docker 版本 19 中,使用 “--security-opt seccomp:unconfined” 选项运行容器时,可以禁用 seccomp 过滤器,允许进程执行任何系统调用。
6074
6175
```shell
6276
docker run --rm \
63-
-e BOT_GITLAB_USERNAME="你的 Gitlab 用户名" \
64-
-e BOT_GITLAB_URL="你的 Gitlab URL" \
65-
-e BOT_GITLAB_TOKEN="你的 Gitlab 访问令牌" \
77+
-e BOT_GITLAB_USERNAME="review-bot" \
78+
-e BOT_GITLAB_URL="http://your-gitlab-instance.com" \
79+
-e BOT_GITLAB_TOKEN="<用户 review-bot 的 access token>" \
6680
-p 9998:9998 \
6781
coolbeevip/gitlab-bot
6882
```
83+
#### 在 GitLab 中设置 Webhook
84+
85+
为了使 GitLab Bot 能够响应事件,您需要在 GitLab 项目中配置 Webhook。请按照以下步骤操作:
86+
87+
1. **打开项目视图**
88+
- 登录到 GitLab。
89+
- 在仪表板中找到并点击您的项目。
90+
91+
2. **进入 Webhook 设置**
92+
- 在左侧边栏菜单中,导航到 `设置` -> `Webhooks`
93+
94+
3. **添加新的 Webhook**
95+
- 点击 `添加新 webhook` 按钮。
96+
97+
4. **填写信息**
98+
- 在出现的表单中,填写以下详细信息:
99+
- **URL**:输入将接收 Webhook 请求的地址,例如 `http://localhost:9998`
100+
- **触发**
101+
- 选择您希望触发 Webhook 的事件,例如:
102+
- `评论`(评论事件)
103+
- `问题事件`(问题事件)
104+
- `合并请求事件`(合并请求事件)
105+
106+
5. **保存 Webhook**
107+
- 点击 `添加 webhook` 按钮以保存您的配置。
69108

109+
6. **测试 Webhook(可选)**
110+
- 为确认 Webhook 是否设置正确,在 Webhooks 列表中找到新添加的 Webhook,并使用 `测试` 按钮发送测试请求。
111+
70112
## 环境变量
71113

72114
**`BOT_GITLAB_USERNAME` / `BOT_GITLAB_URL` / `BOT_GITLAB_TOKEN`**

0 commit comments

Comments
 (0)