Skip to content

Commit

Permalink
fix readme
Browse files Browse the repository at this point in the history
  • Loading branch information
zc2638 committed May 31, 2022
1 parent ed8a849 commit b32a6dd
Show file tree
Hide file tree
Showing 20 changed files with 301 additions and 52 deletions.
16 changes: 16 additions & 0 deletions .gitlab/merge_request_templates/Bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
功能分类:

/kind bugfix

提交内容的简短描述:
<!-- title -->

>
<!-- end title -->
对于reviewer有没有需要特别注意的:
<!-- note -->

>
<!-- end note -->
16 changes: 16 additions & 0 deletions .gitlab/merge_request_templates/CICD.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
功能分类:

/kind ci

提交内容的简短描述:
<!-- title -->

>
<!-- end title -->
对于reviewer有没有需要特别注意的:
<!-- note -->

>
<!-- end note -->
16 changes: 16 additions & 0 deletions .gitlab/merge_request_templates/Cleanup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
功能分类:

/kind cleanup

提交内容的简短描述:
<!-- title -->

>
<!-- end title -->
对于reviewer有没有需要特别注意的:
<!-- note -->

>
<!-- end note -->
16 changes: 16 additions & 0 deletions .gitlab/merge_request_templates/Docs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
功能分类:

/kind docs

提交内容的简短描述:
<!-- title -->

>
<!-- end title -->
对于reviewer有没有需要特别注意的:
<!-- note -->

>
<!-- end note -->
16 changes: 16 additions & 0 deletions .gitlab/merge_request_templates/Feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
功能分类:

/kind feature

提交内容的简短描述:
<!-- title -->

>
<!-- end title -->
对于reviewer有没有需要特别注意的:
<!-- note -->

>
<!-- end note -->
16 changes: 16 additions & 0 deletions .gitlab/merge_request_templates/Merge.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
功能分类:

/kind merge

提交内容的简短描述:
<!-- title -->

>
<!-- end title -->
对于reviewer有没有需要特别注意的:
<!-- note -->

>
<!-- end note -->
16 changes: 16 additions & 0 deletions .gitlab/merge_request_templates/Performance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
功能分类:

/kind pref

提交内容的简短描述:
<!-- title -->

>
<!-- end title -->
对于reviewer有没有需要特别注意的:
<!-- note -->

>
<!-- end note -->
16 changes: 16 additions & 0 deletions .gitlab/merge_request_templates/Refactor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
功能分类:

/kind refactor

提交内容的简短描述:
<!-- title -->

>
<!-- end title -->
对于reviewer有没有需要特别注意的:
<!-- note -->

>
<!-- end note -->
16 changes: 16 additions & 0 deletions .gitlab/merge_request_templates/Style.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
功能分类:

/kind style

提交内容的简短描述:
<!-- title -->

>
<!-- end title -->
对于reviewer有没有需要特别注意的:
<!-- note -->

>
<!-- end note -->
16 changes: 16 additions & 0 deletions .gitlab/merge_request_templates/Test.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
功能分类:

/kind test

提交内容的简短描述:
<!-- title -->

>
<!-- end title -->
对于reviewer有没有需要特别注意的:
<!-- note -->

>
<!-- end note -->
33 changes: 33 additions & 0 deletions .gitlab/review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# can use /lgtm
reviewers:
- reviewer1
- reviewer2

# can use /approve
approvers:
- approver1
- approver2

# merge request settings
pullrequest:
# The merge information is mainly based on the title of PR
# otherwise it is mainly based on the content of <!-- title --><!-- end title --> in PR description template
squash_with_title: true

# custom label settings
custom_labels:
# Operation instructions in comments
- order: /kind cleanup
# Label name associated with the instruction
name: kind/cleanup
# Automatically add prefix for merged submission information
short: cleanup
# Label background color
color: #33a3dc
# Label description
description: "kind: cleanup code"

- order: /area scheduler
name: area/scheduler
color: #96582a
description: "area: scheduler service code area"
112 changes: 74 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,64 +4,49 @@

gitlab review-bot

## Quick start
## Settings

### Config
### Step 1: Create Private Token

change config file in `config/config.yaml`
![](./docs/image/private-token.png)

```
scm:
host: https://gitlab.com
token: <your-private-token>
secret: <your-webhook-secret>
```
### Step 2: Deploy Review Bot

| Configuration Item | Environment Variable | Description |
|:------------------:|:--------------------:|:------------------------------:|
| scm.host | BOT_SCM_HOST | source code management address |
| scm.token | BOT_SCM_TOKEN | private token |
| scm.secret | BOT_SCM_SECRET | webhook secret |

### Run Local

```
go run github.com/zc2638/review-bot/cmd -c config/config.yaml
```

### Run Docker

```
```shell
docker run -d -p 2640:2640 \
-e BOT_SCM_HOST=https://gitlab.com \
-e BOT_SCM_TOKEN=<your-private-token> \
-e BOT_SCM_SECRET=<your-webhook-secret> \
zc2638/review-bot:latest
```

## Note
- `https://gitlab.com` replace with the actual gitlab server address
- `<your-private-token>` replace with the token generated by step1
- `<your-webhook-secret>` replace with a custom password for the webhook, which can be a random string

### Api Document
`GET /swagger-ui`
### Step 3: Generate Webhook Secret

### Generate Webhook Secret
1. Directly access the interface to request to obtain the secret key

`GET /secret?namespace=repo&name=test`
`GET /secret?namespace=zc&name=test`

### Pull Request Template
2. Visit Online API Doc `http://<your-server-address>/swagger/ui`

- Download at url `GET /download?type=gitlab`
- Unzip and move the directory `gitlab` to `.gitlab` in your project
- Modify configuration file `review.yml`
![](./docs/image/webhook-secret.png)

### Step 4: Add Project Webhook

### Setting
![](./docs/image/webhook.png)

- add webhook to associated project, URL is `http://<your-host-address>/webhook`
- the `review-bot` user must have your project permissions
- webhook must set sufficient permissions(e.g. `Comments``Confidential Comments``Pull request events`)

### Custom Config
the configuration file path is in `.gitlab/review.yml`
### Step 5: Add Project Config

Please add the `.gitlab/review.yml` configuration file to the default branch of the project repository.
You can refer to the [`.gitlab` directory](./.gitlab) settings of this project.

```yaml
# can use /lgtm
reviewers:
Expand All @@ -72,12 +57,16 @@ reviewers:
approvers:
- approver1
- approver2

# merge request settings
pullrequest:
# The merge information is mainly based on the title of PR
# otherwise it is mainly based on the content of <!-- title --><!-- end title --> in PR description template
squash_with_title: true

# custom label settings
custom_labels:
# Operation instructions in comments
# Operation instructions in comments
- order: /kind cleanup
# Label name associated with the instruction
name: kind/cleanup
Expand All @@ -92,4 +81,51 @@ custom_labels:
name: area/scheduler
color: #96582a
description: "area: scheduler service code area"
```
```
### Step 6 (optional): Add Merge Request Template
- Download at url `GET /download?type=gitlab`
- Unzip and move the directory `gitlab` to `.gitlab` in your project

You can refer to the [`.gitlab` directory](./.gitlab) settings of this project.

**Please Enjoy it**

## Deploy

### Local

```
go run github.com/zc2638/review-bot/cmd -c config/config.yaml
```
### Docker
```
docker run -d -p 2640:2640 \
-e BOT_SCM_HOST=https://gitlab.com \
-e BOT_SCM_TOKEN=<your-private-token> \
-e BOT_SCM_SECRET=<your-webhook-secret> \
zc2638/review-bot:latest
```
## Config
change config file in `config/config.yaml`
```
server:
port: 2640
scm:
host: https://gitlab.com
token: <your-private-token>
secret: <your-webhook-secret>
```
| Configuration Item | Environment Variable | Description |
|:------------------:|:--------------------:|:------------------------------:|
| server.port | BOT_SERVER_PORT | bot server listening port |
| scm.host | BOT_SCM_HOST | source code management address |
| scm.token | BOT_SCM_TOKEN | private token |
| scm.secret | BOT_SCM_SECRET | webhook secret |
2 changes: 2 additions & 0 deletions config/config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
server:
port: 2640
scm:
host: https://gitlab.com
token: <your-private-token>
Expand Down
Binary file added docs/image/private-token.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/image/webhook-secret.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/image/webhook.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit b32a6dd

Please sign in to comment.