Skip to content

Commit 12b23cb

Browse files
committed
init
Signed-off-by: jwcesign <[email protected]>
0 parents  commit 12b23cb

File tree

28 files changed

+907
-0
lines changed

28 files changed

+907
-0
lines changed

.github/gitautomator.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
owners:
2+
- jwcesign

.github/pull-request-template.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Fixes #
2+
3+
<!-- Please include the 'why' behind your changes if no issue exists -->
4+
## Proposed Changes
5+
6+
*
7+
*
8+
*
9+
10+
**Release Note**
11+
12+
<!-- Enter your extended release note in the below block. If the PR requires
13+
additional action from users switching to the new release, include the string
14+
"action required". If no release note is required, write "NONE". -->
15+
16+
```release-note
17+
18+
```
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: GitAutomator image build and push
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
7+
jobs:
8+
test:
9+
runs-on: ubuntu-20.04
10+
strategy:
11+
fail-fast: true
12+
13+
steps:
14+
- uses: actions/checkout@v3
15+
16+
- name: Set Up QEMU
17+
uses: docker/setup-qemu-action@v3
18+
19+
- name: Set up Docker Buildx
20+
uses: docker/setup-buildx-action@v3
21+
22+
- name: Login to Docker Hub
23+
uses: docker/login-action@v2
24+
with:
25+
username: ${{ secrets.DOCKERHUB_USERNAME }}
26+
password: ${{ secrets.DOCKERHUB_TOKEN }}
27+
28+
- name: GitAutomator - build and push
29+
uses: docker/build-push-action@v3
30+
with:
31+
context: .
32+
file: Dockerfile
33+
platforms: |
34+
linux/amd64
35+
push: true
36+
tags: cesign/gitautomator:latest
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: GitAutomator style check
2+
3+
on:
4+
pull_request:
5+
branches: ["main"]
6+
7+
jobs:
8+
check:
9+
runs-on: ubuntu-latest
10+
strategy:
11+
matrix:
12+
python-version: ["3.11"]
13+
14+
steps:
15+
- uses: actions/checkout@v3
16+
17+
- name: Set up Python ${{ matrix.python-version }}
18+
uses: actions/setup-python@v3
19+
with:
20+
python-version: ${{ matrix.python-version }}
21+
22+
- name: Install dependencies
23+
run: |
24+
python -m pip install --upgrade pip
25+
pip install pylint
26+
pip install typing-extensions
27+
pip install -r requirements.txt
28+
29+
- name: Analysing the code with pylint
30+
run: |
31+
ROOT=$(pwd)
32+
pylint $(git ls-files '*.py') --max-line-length=240
33+
34+
- name: MD link check
35+
uses: gaurav-nelson/github-action-markdown-link-check@v1
36+
with:
37+
use-quiet-mode: "yes"
38+
config-file: ".mdlintrc"
39+
folder-path: "./"
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: GitAutomator image build test
2+
3+
on:
4+
pull_request:
5+
branches: ["main"]
6+
7+
jobs:
8+
test:
9+
runs-on: ubuntu-20.04
10+
strategy:
11+
fail-fast: true
12+
13+
steps:
14+
- uses: actions/checkout@v3
15+
16+
- name: Set Up QEMU
17+
uses: docker/setup-qemu-action@v2
18+
19+
- name: Set up Docker Buildx
20+
uses: docker/setup-buildx-action@v2
21+
22+
- name: Build images
23+
run: |
24+
set -x
25+
docker buildx build --platform linux/amd64 -t cesign/gitautomator:latest -f Dockerfile --load ./

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__pycache__

.pylintrc

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
[MASTER]
2+
disable=
3+
C0114, # missing-module-docstring
4+
C0115, # missing-class-docstring
5+
C0116, # missing-class-docstring
6+
W0703, # broad-except
7+
W0511, # fixme, like TODO
8+
R1732, # consider-using-with
9+
C0201, # consider-iterating-dictionary
10+
I1101, # Module 'libtorrent' has no 'torrent_info' member
11+
W0719, # Raising too general exception
12+
R0902, # Too many instance attributes
13+
R1714, # onsider merging these comparisons with 'in'
14+
R0903, # Too few public methods
15+
R0913, # Too many arguments
16+
R0911, # Too many return statements
17+
W4905, # Using deprecated decorator abc.abstractproperty()
18+
19+
[SIMILARITIES]
20+
# Minimum lines number of a similarity.
21+
min-similarity-lines=100
22+
23+
# Ignore comments when computing similarities.
24+
ignore-comments=yes
25+
26+
# Ignore docstrings when computing similarities.
27+
ignore-docstrings=yes
28+
29+
# Ignore imports when computing similarities.
30+
ignore-imports=no
31+
32+
[FORMAT]
33+
# Maximum number of characters on a single line.
34+
max-line-length=240
35+
36+
[BASIC]
37+
# Regular expression matching correct method names
38+
# Pylint do not complain for setUp and other if it
39+
# detects that we inherit from unittest.TestCase
40+
# But that's not always possible to detect.
41+
method-rgx=[a-z_][a-z0-9_]{2,30}$|do_POST(Class)?

Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# syntax=docker/dockerfile:1
2+
3+
FROM python:3.10-alpine
4+
5+
WORKDIR /app
6+
COPY ./bots ./bots
7+
COPY ./app.py ./
8+
COPY requirements.txt ./
9+
10+
RUN set -ex \
11+
&& apk add --no-cache git \
12+
&& python3 -m pip install --upgrade pip \
13+
&& pip install -r requirements.txt
14+
15+
ENTRYPOINT [ "python", "app.py" ]

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 jwcesign
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
<div align="center">
2+
<a href="https://github.com/apps/gitautomator"><img height="100px" alt="logo" src="./images/logo.png"></a>
3+
<p>
4+
<em>A smart automated GitHub bot for managing GitHub projects.</em>
5+
</p>
6+
<div>
7+
<a href="#">
8+
<img src="https://img.shields.io/badge/python-3.11-blue" />
9+
</a>
10+
<a href="https://github.com/jwcesign/gitautomator/blob/main/LICENSE">
11+
<img src="https://img.shields.io/github/license/jwcesign/gitautomator" alt="License" />
12+
</a>
13+
<a href="https://github.com/jwcesign/gitautomator/stargazers">
14+
<img src="https://img.shields.io/github/stars/jwcesign/gitautomator?style=plastic" />
15+
</a>
16+
</div>
17+
</div>
18+
19+
## ❤️ Introduction
20+
21+
GitAutomator responds to various events in your repository, acting as a smart assistant to enhance maintenance efficiency.
22+
23+
## 💾 Installation
24+
25+
Visit the relevant [GitHub APP](https://github.com/apps/gitautomator) page to install GitAutomator. After installation, comment `/cat` on an issue or PR to check its functionality.
26+
27+
## ⛵ Plugins and Functions
28+
29+
| Name | Description |
30+
| ---- | ----------- |
31+
| cat | To verify if GitAutomator functions properly with your repository, use the `/cat` command in an issue or PR |
32+
| ailabel | GitAutomator will utilize ChatGPT to label an issue or PR based on the labels in your repository and the issue/PR content |
33+
| aireleasenote | GitAutomator checks the release note block<sup>[1]</sup>, assesses its appropriateness, and provides notifications |
34+
| approve | GitAutomator will approve and merge a PR when the maintainer comments `/approve` |
35+
| cherrypick | GitAutomator will cherry-pick the commits of the PR to another `<target_branch>` when the maintainer comments `/cherry-pick <target_branch>` |
36+
| label | GitAutomator will add `<target_label>` to the PR or issue when an account comments `/label <target_label>` |
37+
| prcomment | GitAutomator will post a thank you comment when a new PR is submitted |
38+
| prlabel | GitAutomator will label a PR based on its title; it will label a title prefixed with `fix` as `bug`, `doc` as `documentation`, and `feat` as `enhancement` |
39+
| prreact | GitAutomator will react with a heart when a new PR is submitted |
40+
| prreviewrequest | GitAutomator will automatically request reviews from the maintainers configured in `.github/gitautomator.yaml` |
41+
42+
* **[1]**: The PR body should contain the following block:
43+
44+
<img src="./images/release-note.png" width="400px">
45+
46+
This could work excellently if you're looking to automatically generate polished release notes. Feel free to use this [template](./.github/pull-request-template.md) for your PR.
47+
48+
## 📃 Configuration
49+
50+
You can define the specific behavior by configuring the `.github/gitautomator.yaml` file in your repository. The complete configuration is as follows:
51+
```yaml
52+
owners:
53+
- jwcesign # This identifies the maintainer of this repository. GitAutomator will request reviews from them for any new PR.
54+
plugins:
55+
- cat # This identifies the plugins to enable. If left blank, all plugins will be enabled.
56+
```
57+
58+
## 🚀 Self Hosting Guide
59+
60+
Use the official GitHub App to manage your code repository. You can also deploy this App on a self-hosted server. Here are the detailed instructions.
61+
62+
### Create GitHub App
63+
64+
First, you need to create a GitHub app. GitHub itself [documents this](https://docs.github.com/en/apps/creating-github-apps/registering-a-github-app/registering-a-github-app). Below is the set of permissions needed.
65+
66+
Repository permissions:
67+
68+
* Commit statuses: Read and write
69+
* Contents: Read and write
70+
* Merge queues: Read and write
71+
* Metadata: Read-only
72+
* Pull requests: Read and write
73+
* Issues: Read and write
74+
75+
In Subscribe to events select following events:
76+
* Commit comment
77+
* Issue comment
78+
* Issues
79+
* Label
80+
* Merge group
81+
* Merge queue entry
82+
* Pull request
83+
84+
### Obtain App ID and Private Key
85+
86+
After creating a GitHub App, download the private key as `app.pem` in the current directory and remember the App ID.
87+
88+
### Create a Webhook Channel
89+
90+
Visit [https://smee.io](https://smee.io) to create a new channel, and remember the webhook proxy URL.
91+
92+
### Configure GitHub App Webhook URL
93+
94+
Navigate to the GitHub App settings page, and fill the App's webhook URL field with the Smee webhook proxy URL.
95+
96+
### Launch the Service
97+
98+
1. Clone repository:
99+
```sh
100+
git clone https://github.com/jwcesign/gitautomator.git
101+
```
102+
103+
2. Export the necessary environment variables:
104+
```sh
105+
export APP_ID=xxx
106+
export SMEEIO_URL=xxx
107+
export CHATGPT_URL=https://api.openai.com/v1 # you can set another URL
108+
export OPENAI_KEY=xxx # your OpenAI secret key
109+
```
110+
111+
3. Run the container service:
112+
```
113+
docker-compose up -d
114+
```
115+
116+
4. Enjoy your time!
117+
118+
## 🤝 Contribution
119+
120+
If you are interested in participating in joint development, welcome to STAR/FORK/PR.

0 commit comments

Comments
 (0)