A GitHub Actions bot that assists with PR management, workflow retries, and automated feedback.
- PR Comment Commands: Responds to commands in PR comments
- Workflow Management: Retry failed workflows and CI checks
- Automated Feedback: Provides helpful comments on PRs with status and next steps
- CI Status Reports: Summarizes CI/CD status in PR comments
The bot responds to the following commands in PR comments:
/retry- Retry all failed workflows/retry <workflow-name>- Retry a specific workflow/test- Run tests again/status- Show current CI/CD status/help- Show available commands
The bot is already integrated! The workflow file .github/workflows/fanex-id-bot.yml is included in the main repository.
To activate the bot:
- The workflow is already in place at
.github/workflows/fanex-id-bot.yml - The bot will automatically respond to PR comments and events
- No additional configuration needed (uses default GitHub token)
If you want to use this bot in another repository:
- Copy the
fanex-id-botdirectory to your repository - Add the workflow file to
.github/workflows/fanex-id-bot.yml:
name: faneX-ID Bot
on:
issue_comment:
types: [created]
pull_request:
types: [opened, synchronize, reopened]
permissions:
contents: read
pull-requests: write
actions: write
jobs:
bot:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.12'
- name: Install dependencies
run: pip install PyGithub requests PyYAML PyJWT cryptography
# Optional: Generate GitHub App Token (if secrets are configured)
# This allows the bot to post as "faneX-ID Bot" instead of "github-actions[bot]"
- name: Generate GitHub App Token
id: app_token
if: ${{ secrets.FANEX_BOT_APP_ID != '' && secrets.FANEX_BOT_PRIVATE_KEY != '' }}
run: |
# Create a temporary script to generate the token
cat > generate_token.py << 'EOF'
import jwt
import time
import sys
import os
app_id = os.environ['APP_ID']
private_key = os.environ['PRIVATE_KEY']
# Generate JWT
now = int(time.time())
payload = {
'iat': now - 60,
'exp': now + (10 * 60),
'iss': app_id
}
token = jwt.encode(payload, private_key, algorithm='RS256')
print(f"::set-output name=token::{token}")
EOF
python generate_token.py
env:
APP_ID: ${{ secrets.FANEX_BOT_APP_ID }}
PRIVATE_KEY: ${{ secrets.FANEX_BOT_PRIVATE_KEY }}
- name: Run bot
env:
# Use GitHub App token if available, otherwise fall back to GITHUB_TOKEN
FANEX_BOT_TOKEN: ${{ steps.app_token.outputs.token }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_EVENT_PATH: ${{ github.event_path }}
run: |
# Determine which token to use
if [ -n "$FANEX_BOT_TOKEN" ]; then
echo "✅ Using GitHub App token - comments will appear as faneX-ID Bot"
export GITHUB_TOKEN="$FANEX_BOT_TOKEN"
else
echo "ℹ️ Using GITHUB_TOKEN - comments will appear as github-actions[bot]"
echo " To use faneX-ID Bot identity, set secrets: FANEX_BOT_APP_ID and FANEX_BOT_PRIVATE_KEY"
fi
python demo_repos/fanex-id-bot/bot.pyThe workflow supports two authentication methods:
Required Secrets:
FANEX_BOT_APP_ID: Your GitHub App IDFANEX_BOT_PRIVATE_KEY: Your GitHub App private key (full PEM content)
Benefits:
- Comments appear as "faneX-ID Bot" instead of "github-actions[bot]"
- Better user experience and clearer bot identity
- More professional appearance
Setup: See Token Configuration section above.
No configuration needed - uses the automatically provided GITHUB_TOKEN.
Limitations:
- Comments appear as "github-actions[bot]"
- Less personalized bot identity
Token Priority:
- If
FANEX_BOT_APP_IDandFANEX_BOT_PRIVATE_KEYsecrets are set, the workflow will generate a GitHub App token - Otherwise, it falls back to the default
GITHUB_TOKEN
- Copy the
fanex-id-botdirectory to your repository - Add the workflow file to
.github/workflows/ - The bot will automatically respond to PR comments
The bot supports two authentication methods:
Using a GitHub App token allows the bot to post comments as "faneX-ID Bot" instead of "github-actions[bot]". This provides a better user experience and clearer bot identity.
- Go to your organization or user settings
- Navigate to Developer settings → GitHub Apps
- Click New GitHub App
- Configure the app:
- Name:
faneX-ID Bot(or your preferred name) - Homepage URL: Your repository URL
- Webhook: Optional (not needed for this bot)
- Permissions:
- Repository permissions:
- Contents:
Read - Pull requests:
Write - Actions:
Write - Issues:
Write(for comments)
- Contents:
- Repository permissions:
- Where can this GitHub App be installed?: Choose your organization or account
- Name:
- Click Create GitHub App
- After creating the app, scroll down to Private keys
- Click Generate a private key
- Save the downloaded
.pemfile securely (you'll need this for the secret)
- Click Install App in the app settings
- Select the organization or account where you want to install it
- Select the repositories (or all repositories)
- Click Install
- In the app settings, note the App ID (you'll need this for the secret)
Add the following secrets to your repository (Settings → Secrets and variables → Actions):
FANEX_BOT_APP_ID: The App ID from step 4 (e.g.,123456)FANEX_BOT_PRIVATE_KEY: The entire contents of the.pemfile from step 2
Example of private key format:
-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEA...
(multiple lines)
...
-----END RSA PRIVATE KEY-----
The workflow will automatically detect these secrets and generate a token. No additional changes needed if using the provided workflow template.
If you don't configure a GitHub App, the bot will use the default GITHUB_TOKEN provided by GitHub Actions. This works out of the box but comments will appear as "github-actions[bot]".
No configuration needed - the GITHUB_TOKEN is automatically available in GitHub Actions workflows.
The bot uses tokens in this order:
FANEX_BOT_TOKEN(if GitHub App is configured)GITHUB_TOKEN(fallback, always available)
The bot can be configured via environment variables:
BOT_ENABLED: Enable/disable the bot (default:true)ADMIN_USERS: Comma-separated list of admin usernamesAUTO_RETRY: Automatically retry failed workflows (default:false)
Retries all failed workflows for the current PR.
Example:
/retry
Retries a specific workflow by name.
Example:
/retry backend-ci
Runs the test suite again.
Example:
/test
Shows the current status of all CI/CD checks.
Example:
/status
Shows available commands and usage.
Example:
/help
The bot consists of:
bot.py: Main bot logic and command processorworkflow_manager.py: Handles workflow retries and status checkscomment_handler.py: Processes PR comments and respondsaction.yml: GitHub Action definition
Use this checklist to set up the bot with a GitHub App token:
- Create GitHub App in organization/user settings
- Configure app permissions (Contents: Read, Pull requests: Write, Actions: Write, Issues: Write)
- Generate and download private key (.pem file)
- Install the app to your organization/account
- Note the App ID from app settings
- Add
FANEX_BOT_APP_IDsecret to repository (Settings → Secrets → Actions) - Add
FANEX_BOT_PRIVATE_KEYsecret to repository (full PEM content, including-----BEGIN RSA PRIVATE KEY-----and-----END RSA PRIVATE KEY-----) - Test the workflow - bot comments should appear as "faneX-ID Bot"
Cause: GitHub App token is not configured or not being generated.
Solutions:
- Verify secrets are set correctly:
- Go to repository Settings → Secrets and variables → Actions
- Check that
FANEX_BOT_APP_IDandFANEX_BOT_PRIVATE_KEYexist
- Verify private key format:
- Must include
-----BEGIN RSA PRIVATE KEY-----at the start - Must include
-----END RSA PRIVATE KEY-----at the end - Must include all lines in between (no truncation)
- Must include
- Check workflow logs:
- Look for "Generate GitHub App Token" step
- Verify it runs (should show "✅ Using GitHub App token" if successful)
Common issues:
- Invalid App ID: Ensure
FANEX_BOT_APP_IDis a numeric value (e.g.,123456) - Invalid private key: Ensure the entire PEM file content is copied, including headers
- App not installed: Install the GitHub App to your organization/account
- Insufficient permissions: Verify app has required permissions (Pull requests: Write, Actions: Write)
Check:
- Workflow is enabled and running
- Bot has write permissions to pull requests
- Commands are formatted correctly (e.g.,
/retryon its own line) - Comment is on a PR (not an issue)
To test the bot locally:
# Set environment variables
export GITHUB_TOKEN="your_token_here"
export GITHUB_REPOSITORY="owner/repo"
export GITHUB_EVENT_PATH="path/to/event.json"
# Run bot
python bot.pyFor testing with GitHub App token:
# Generate token first (requires APP_ID and PRIVATE_KEY)
export APP_ID="your_app_id"
export PRIVATE_KEY="$(cat path/to/private-key.pem)"
python scripts/generate_app_token.py
# Then use the generated token
export FANEX_BOT_TOKEN="generated_token"
export GITHUB_REPOSITORY="owner/repo"
python bot.pyThis project is licensed under the GNU Affero General Public License v3.0 (AGPL-3.0) - see the LICENSE file for details.