βββββββ βββββββββββββββ ββββββ ββββββββββ ββββ ββββ βββββββ ββββ βββββββββββββββ βββββββ βββββββ
ββββββββ βββββββββββββββ ββββββ βββββββββββ βββββ βββββββββββββββββββ ββββββββββββββββββββββββββββββββ
βββ βββββββ βββ βββββββββββ βββββββββββ ββββββββββββββ βββββββββ ββββββ βββ βββ βββββββββββ
βββ ββββββ βββ βββββββββββ βββββββββββ ββββββββββββββ ββββββββββββββββ βββ βββ βββββββββββ
ββββββββββββ βββ βββ ββββββββββββββββββββ βββ βββ βββββββββββββββ βββββββββ βββ ββββββββββββ βββ
βββββββ βββ βββ βββ βββ βββββββ βββββββ βββ βββ βββββββ βββ ββββββββ βββ βββββββ βββ βββ
A powerful and efficient Python application to monitor changes in GitHub organization repositories with secure token management, beautiful terminal output, and optional Slack notifications.
- π Efficient Repository Tracking: Monitors any GitHub organization for repository additions and deletions
- π Optimized Performance: O(n log n) time complexity for repository comparisons
- π Automatic Change Detection: Detects new and deleted repositories between runs
- π¨ Beautiful Terminal Output: Color-coded tables and styled content in the terminal
- π± Slack Integration: Optional notifications for changes via Slack webhooks
- π Detailed Logging: Comprehensive timestamped logs with severity levels
- π Error Handling: Robust error catching and reporting
- πΎ Automatic Backups: Keeps history of previous runs with dated backups
- βοΈ Customizable: Command-line options for organization, tokens, and more
- π Secure Token Storage: Securely stores GitHub tokens and credentials
- π Automatic Retries: Handles network issues with automatic retries
- β Token & Organization Validation: Validates tokens and organizations before running
- π Configuration Management: Dedicated utility for managing configurations
- π User-specific Config: Stores settings in user's home config directory
- Python 3.6+
- Required Python packages (specified in requirements.txt):
- requests
- colorama
- rich
- configparser
- Clone this repository or download the Python scripts
- Install required Python packages:
pip install -r requirements.txt- Set up your configuration (GitHub token and organization):
python setup_config.py- Make the script executable (optional):
chmod +x github_monitor.pyFirst, set up your configuration using the dedicated configuration utility:
python setup_config.pyThis interactive utility will help you securely configure:
-
--org: GitHub organization name -
--token: GitHub API token (validated during setup) -
--slack: Slack webhook URL (if needed) -
--enable_slack: Slack notification preferences
Run the monitor using your stored configuration:
python github_monitor.pyOverride stored configuration or use additional options:
python github_monitor.py [OPTIONS]Available options:
--help: Show help message--org NAME: Override GitHub organization name--token TOKEN: Override GitHub API token--slack URL: Override Slack webhook URL--enable-slack: Enable Slack notifications using stored webhook URL--show-config: Display current configuration--dry-run: Run without making changes (for testing)
Show current configuration:
python github_monitor.py --show-configMonitor a specific organization (overriding stored config):
python github_monitor.py --org MicrosoftUse with a different GitHub token:
python github_monitor.py --token your_github_token_hereEnable Slack notifications with a new webhook URL:
python github_monitor.py --slack https://hooks.slack.com/services/your/webhook/urlEnable Slack notifications using the stored webhook URL:
python github_monitor.py --enable-slack +-----------------------+
| |
| GitHub API |
| |
+-----------------------+
^ |
| |
| | HTTP/HTTPS
| | Requests
| v
+------------------------+ +------------------------+
| | | |
| Configuration Manager |<---->| GitHub Repository |
| (setup_config.py) | | Monitor |
| | | (github_monitor.py) |
+------------------------+ +------------------------+
^ | | ^
| | | |
| v v |
+------------------------+ +------------------------+
| | | |
| User Config Directory | | Repository Lists |
| (~/.config/github- |<---->| - Current (today.txt) |
| monitor/config.ini) | | - Previous (hist.txt) |
| | | |
+------------------------+ +------------------------+
| ^
| |
v |
+---------------------------------------+
| |
| Output Channels |
| - Console (Rich Formatted Output) |
| - Log File (Timestamped, Structured) |
| - Slack (Optional Notifications) |
| |
+---------------------------------------+
βββββββββββββββββββββββββββββββββββββββββ
β Configuration Management β
βββββββββββββββββββββββββββββββββββββββββ€
β 1. Load user configuration β
β 2. Process command-line arguments β
β 3. Validate GitHub token β
β 4. Validate organization access β
βββββββββββββββββββββββββββββ¬ββββββββββββ
βΌ
βββββββββββββββββββββββββββββββββββββββββ
β Data Collection β
βββββββββββββββββββββββββββββββββββββββββ€
β 5. Backup existing files β
β 6. Fetch repositories with pagination β
β 7. Save current repository list β
βββββββββββββββββββββββββββββ¬ββββββββββββ
βΌ
βββββββββββββββββββββββββββββββββββββββββ
β Change Detection β
βββββββββββββββββββββββββββββββββββββββββ€
β 8. Find previous repository list β
β 9. Compare current with previous list β
β10. Identify added & deleted repos β
βββββββββββββββββββββββββββββ¬ββββββββββββ
βΌ
βββββββββββββββββββββββββββββββββββββββββ
β Reporting β
βββββββββββββββββββββββββββββββββββββββββ€
β11. Generate terminal report β
β12. Send Slack notifications (optional)β
β13. Log all activities β
βββββββββββββββββββββββββββββββββββββββββ
GitHub Repository Monitor Configuration
GitHub Token Configuration
β Token valid! Authenticated as: Zero0x00
GitHub token updated and validated successfully
GitHub Organization Configuration
β Organization 'GooseX' exists and is accessible
Organization 'GooseX' validated and saved
β Configuration saved to /home/kali/.config/github-monitor/config.ini
Configuration Summary:
Organization: GooseX
GitHub token: ********5048
Slack webhook: ********************Not set
Slack notifications: Disabled
You can also use command-line arguments with the configuration utility:
python setup_config.py --token YOUR_TOKEN --org GooseX[2025-05-21 05:51:51] [INFO] GitHub Repository Monitor initialized
[2025-05-21 05:51:51] [INFO] GitHub token validated successfully
[2025-05-21 05:51:52] [INFO] Organization 'GooseX' validated successfully
================================================================================
GitHub Repository Monitor
================================================================================
[2025-05-21 05:51:52] [INFO] Starting repository monitoring for GooseX
[2025-05-21 05:51:52] [INFO] Backing up existing files
[2025-05-21 05:51:52] [INFO] Fetching repositories for GooseX
[2025-05-21 05:51:56] [INFO] Retrieved 100 repositories on page 1 (total: 100)
[2025-05-21 05:51:59] [INFO] Retrieved 78 repositories on page 2 (total: 178)
[2025-05-21 05:51:59] [INFO] Successfully fetched 178 repositories
================================================================================
Repository Changes Report
================================================================================
ββββββββββββββββββββββββββββββββββββββββββββββββ
Added Repositories
ββββββββββββββββββββββββββββββββββββββββββββββββ
Total count: 2
β’ GooseX/Web-R
β’ GooseX/Web-TM
ββββββββββββββββββββββββββββββββββββββββββββββββ
ββββββββββββββββββββββββββββββββββββββββββββββββ
Deleted Repositories
ββββββββββββββββββββββββββββββββββββββββββββββββ
Total count: 1
β’ GooseX/asdadas
ββββββββββββββββββββββββββββββββββββββββββββββββ
[2025-05-21 05:51:59] [INFO] Script completed successfully
[2025-05-21 05:46:05] [INFO] No previous repository list found. This is the first run.
================================================================================
Initial Repository Report
================================================================================
ββββββββββββββββββββββββββββββββββββββββββββββββ
Current Repositories
ββββββββββββββββββββββββββββββββββββββββββββββββ
Total count: 178
Too many items to display (178 repositories)
Results saved to file
ββββββββββββββββββββββββββββββββββββββββββββββββ
This application securely stores your GitHub token in your user's config directory (~/.config/github-monitor/config.ini) with restricted permissions (600 - readable only by the owner).
For reliable operation, it's recommended to use a GitHub token to avoid API rate limits. You can create a personal access token at GitHub with the repo scope or the minimum required scopes for reading organization repositories.
The setup utility validates your token during configuration to ensure it works correctly before saving it:
- Verifies the token is valid by authenticating with GitHub API
- Confirms it has access to the specified organization
- Securely saves the token with proper file permissions
- Never share your GitHub token
- Use tokens with the minimum required permissions
- Rotate tokens periodically for improved security
- Monitor token usage in your GitHub account settings
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions, issues, and feature requests are welcome!
- Fork the project
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Connect with the creator on LinkedIn
sequenceDiagram
participant User
participant github_monitor.py
participant GitHub API
participant Config File
participant Repository Lists
participant Output Channels
User->>github_monitor.py: Execute script
github_monitor.py->>Config File: Load configuration
github_monitor.py->>GitHub API: Validate token and organization
alt Validation failed
github_monitor.py->>User: Display error
else Validation successful
github_monitor.py->>Repository Lists: Backup existing files
github_monitor.py->>GitHub API: Fetch repositories
GitHub API-->>github_monitor.py: Return repositories
github_monitor.py->>Repository Lists: Save current repository list
github_monitor.py->>Repository Lists: Find previous repository list
alt Previous list exists
github_monitor.py->>Repository Lists: Load previous repository list
github_monitor.py->>github_monitor.py: Compare current and previous lists
github_monitor.py->>Output Channels: Generate terminal report
alt Slack enabled
github_monitor.py->>Output Channels: Send Slack notification
end
else No previous list
github_monitor.py->>Output Channels: Generate initial repository report
end
github_monitor.py->>Output Channels: Log activities
end