Skip to content

Commit 11858c4

Browse files
committed
Initial release of new bot
1 parent 7fc2e15 commit 11858c4

File tree

9 files changed

+891
-2
lines changed

9 files changed

+891
-2
lines changed

.github/workflows/bot.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: faneX-ID Bot
2+
3+
on:
4+
issue_comment:
5+
types: [created]
6+
pull_request:
7+
types: [opened, synchronize, reopened]
8+
9+
permissions:
10+
contents: read
11+
pull-requests: write
12+
actions: write
13+
14+
jobs:
15+
bot:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v6
20+
21+
- name: Set up Python
22+
uses: actions/setup-python@v6
23+
with:
24+
python-version: '3.12'
25+
26+
- name: Install dependencies
27+
run: |
28+
pip install PyGithub requests
29+
30+
- name: Run bot
31+
env:
32+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33+
GITHUB_REPOSITORY: ${{ github.repository }}
34+
GITHUB_EVENT_PATH: ${{ github.event_path }}
35+
run: |
36+
python demo_repos/fanex-id-bot/bot.py

README.md

Lines changed: 146 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,146 @@
1-
# github-bot
2-
faneX-ID Github PR & workflow helper bot
1+
# faneX-ID Bot
2+
3+
A GitHub Actions bot that assists with PR management, workflow retries, and automated feedback.
4+
5+
## Features
6+
7+
- **PR Comment Commands**: Responds to commands in PR comments
8+
- **Workflow Management**: Retry failed workflows and CI checks
9+
- **Automated Feedback**: Provides helpful comments on PRs with status and next steps
10+
- **CI Status Reports**: Summarizes CI/CD status in PR comments
11+
12+
## Supported Commands
13+
14+
The bot responds to the following commands in PR comments:
15+
16+
- `/retry` - Retry all failed workflows
17+
- `/retry <workflow-name>` - Retry a specific workflow
18+
- `/test` - Run tests again
19+
- `/status` - Show current CI/CD status
20+
- `/help` - Show available commands
21+
22+
## Usage
23+
24+
### Installation in faneX-ID Repository
25+
26+
The bot is already integrated! The workflow file `.github/workflows/fanex-id-bot.yml` is included in the main repository.
27+
28+
To activate the bot:
29+
30+
1. The workflow is already in place at `.github/workflows/fanex-id-bot.yml`
31+
2. The bot will automatically respond to PR comments and events
32+
3. No additional configuration needed (uses default GitHub token)
33+
34+
### Manual Installation
35+
36+
If you want to use this bot in another repository:
37+
38+
1. Copy the `fanex-id-bot` directory to your repository
39+
2. Add the workflow file to `.github/workflows/fanex-id-bot.yml`:
40+
41+
```yaml
42+
name: faneX-ID Bot
43+
44+
on:
45+
issue_comment:
46+
types: [created]
47+
pull_request:
48+
types: [opened, synchronize, reopened]
49+
50+
permissions:
51+
contents: read
52+
pull-requests: write
53+
actions: write
54+
55+
jobs:
56+
bot:
57+
runs-on: ubuntu-latest
58+
steps:
59+
- uses: actions/checkout@v6
60+
- uses: actions/setup-python@v6
61+
with:
62+
python-version: '3.12'
63+
- run: pip install PyGithub requests
64+
- run: python demo_repos/fanex-id-bot/bot.py
65+
env:
66+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67+
GITHUB_REPOSITORY: ${{ github.repository }}
68+
GITHUB_EVENT_PATH: ${{ github.event_path }}
69+
```
70+
71+
### Installation
72+
73+
1. Copy the `fanex-id-bot` directory to your repository
74+
2. Add the workflow file to `.github/workflows/`
75+
3. The bot will automatically respond to PR comments
76+
77+
## Configuration
78+
79+
The bot can be configured via environment variables:
80+
81+
- `BOT_ENABLED`: Enable/disable the bot (default: `true`)
82+
- `ADMIN_USERS`: Comma-separated list of admin usernames
83+
- `AUTO_RETRY`: Automatically retry failed workflows (default: `false`)
84+
85+
## Commands Reference
86+
87+
### `/retry`
88+
Retries all failed workflows for the current PR.
89+
90+
**Example:**
91+
```
92+
/retry
93+
```
94+
95+
### `/retry <workflow-name>`
96+
Retries a specific workflow by name.
97+
98+
**Example:**
99+
```
100+
/retry backend-ci
101+
```
102+
103+
### `/test`
104+
Runs the test suite again.
105+
106+
**Example:**
107+
```
108+
/test
109+
```
110+
111+
### `/status`
112+
Shows the current status of all CI/CD checks.
113+
114+
**Example:**
115+
```
116+
/status
117+
```
118+
119+
### `/help`
120+
Shows available commands and usage.
121+
122+
**Example:**
123+
```
124+
/help
125+
```
126+
127+
## Architecture
128+
129+
The bot consists of:
130+
131+
- **`bot.py`**: Main bot logic and command processor
132+
- **`workflow_manager.py`**: Handles workflow retries and status checks
133+
- **`comment_handler.py`**: Processes PR comments and responds
134+
- **`action.yml`**: GitHub Action definition
135+
136+
## Development
137+
138+
To test the bot locally:
139+
140+
```bash
141+
python bot.py --test
142+
```
143+
144+
## License
145+
146+
Part of the faneX-ID project.

action.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: 'faneX-ID Bot'
2+
description: 'GitHub Actions bot for PR management and workflow automation'
3+
author: 'faneX-ID Team'
4+
5+
inputs:
6+
github-token:
7+
description: 'GitHub token for API access'
8+
required: true
9+
enabled:
10+
description: 'Enable the bot'
11+
required: false
12+
default: 'true'
13+
14+
runs:
15+
using: 'composite'
16+
steps:
17+
- name: Set up Python
18+
uses: actions/setup-python@v6
19+
with:
20+
python-version: '3.12'
21+
22+
- name: Install dependencies
23+
shell: bash
24+
run: |
25+
pip install PyGithub requests
26+
27+
- name: Run bot
28+
shell: bash
29+
env:
30+
GITHUB_TOKEN: ${{ inputs.github-token }}
31+
GITHUB_REPOSITORY: ${{ github.repository }}
32+
GITHUB_EVENT_PATH: ${{ github.event_path }}
33+
run: |
34+
python bot.py

0 commit comments

Comments
 (0)