How turancannb02/github-automation-for-customgpt works
Project Type and Purpose
• This is a lightweight, Python-based CLI automation tool that orchestrates AI-driven code changes on GitHub.
• It calls a Custom GPT model to decide or generate edits, then uses the GitHub REST API to create branches, update files, and open pull requests.
File Structure Analysis
• Top-level files:
– github-automation.py: the single Python script containing all orchestration logic, HTTP calls, and GPT integration.
– README.md: describes purpose, API endpoints invoked, and configuration.
– .idea/: IDE config (not part of runtime).
• No separate frontend/backend or persistence layers—this is purely an orchestration script that invokes external services.
Key Components (to show
A. User / Trigger
• A developer or CI job (e.g., GitHub Actions, cron) invokes github-automation.py.
B. Python Automation Module (github-automation.py)
1. Configuration Loader (reads API tokens, default branch)
2. Custom GPT Client
• Sends prompts to the GPT endpoint to generate commit messages or patch content.
3. GitHub API Client
• getLatestSHA, createBranch, getRepositoryFile, updateRepositoryFile, createPullRequest functions.
4. Core Orchestrator
• Implements the flow: fetch SHA → branch → fetch file → patch via GPT → push update → open PR.
C. External Services
1. Custom GPT Model API (OpenAI or self-hosted)
2. GitHub REST API
Relationships and Data Flow
1. Trigger → Python Automation
2. Automation → (1) GPT API: “Here’s file content; suggest fix” → receives proposed diff/content.
3. Automation → (2) GitHub API:
a. GET latest commit SHA
b. POST new branch ref
c. GET existing file contents
d. Updated file (Base64)
e. POST new pull request
4. GitHub API → Automation: returns status/responses
5. Automation → User/CI: logs success or PR URL
Architectural Patterns & Principles
• Single Responsibility: distinct functions for each GitHub endpoint and GPT call.
• Clear separation of concerns:
• Config/credentials loading
• AI-driven content generation
• Git operations via REST
• No persistence; stateless orchestration.
Technologies & Frameworks
• Python 3.x
• HTTP client (e.g., requests)
• GitHub REST API
• OpenAI / Custom GPT API
• CLI or CI/CD runner (trigger mechanism)