|
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. |
0 commit comments