{"id":18099389,"url":"https://github.com/sinless777/pr-creator","last_synced_at":"2026-05-05T00:38:00.185Z","repository":{"id":260323634,"uuid":"877172366","full_name":"Sinless777/PR-Creator","owner":"Sinless777","description":"Automatically creates a pull request with OpenAI-generated titles and descriptions when code is pushed to a branch without an existing PR. This action validates commit messages and generates meaningful PR content, simplifying your workflow with the power of GPT-3.","archived":false,"fork":false,"pushed_at":"2025-03-27T19:41:04.000Z","size":20,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-27T20:34:08.320Z","etag":null,"topics":["bash","github-actions","openai","pull-requests","python"],"latest_commit_sha":null,"homepage":"https://sinless777.github.io/PR-Creator/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Sinless777.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-23T08:02:13.000Z","updated_at":"2024-10-23T10:50:50.000Z","dependencies_parsed_at":"2024-10-30T18:32:20.076Z","dependency_job_id":"b92b0161-cc40-4ab1-a6c1-597b8d0d5118","html_url":"https://github.com/Sinless777/PR-Creator","commit_stats":null,"previous_names":["sinless777/pr-creator"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sinless777%2FPR-Creator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sinless777%2FPR-Creator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sinless777%2FPR-Creator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sinless777%2FPR-Creator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Sinless777","download_url":"https://codeload.github.com/Sinless777/PR-Creator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247435026,"owners_count":20938530,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bash","github-actions","openai","pull-requests","python"],"created_at":"2024-10-31T21:08:27.232Z","updated_at":"2026-05-05T00:38:00.143Z","avatar_url":"https://github.com/Sinless777.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PR Creator with OpenAI\n\nAutomatically create a Pull Request (PR) with OpenAI-generated content when code is pushed to a branch without an existing PR. This GitHub Action uses Python and Bash to automate the PR creation process, including generating PR titles, descriptions, and comments using OpenAI's GPT-3 language model.\n\n## Table of Contents\n\n- [Features](#features)\n- [Prerequisites](#prerequisites)\n- [Usage](#usage)\n  - [Inputs](#inputs)\n  - [Example Workflow](#example-workflow)\n- [Setup Instructions](#setup-instructions)\n  - [OpenAI API Key](#openai-api-key)\n  - [GitHub Token](#github-token)\n- [Customization](#customization)\n- [Error Handling](#error-handling)\n- [Development](#development)\n  - [Local Testing](#local-testing)\n  - [Building the Docker Image](#building-the-docker-image)\n- [Contributing](#contributing)\n- [License](#license)\n- [Acknowledgements](#acknowledgements)\n\n## Features\n\n- **Automatic PR Creation**: Creates a PR when code is pushed to a branch without an existing PR.\n- **OpenAI Integration**: Generates PR titles, descriptions, and comments using GPT-3.\n- **Commit Message Validation**: Validates commit messages against conventional commit standards using `commitlint`.\n- **Rate Limit Handling**: Implements retries with exponential backoff to handle API rate limits gracefully.\n- **Customizable Parameters**: Allows customization of OpenAI parameters and commit history length.\n- **Robust Error Handling**: Provides detailed input validation and error messages.\n\n## Prerequisites\n\n- A GitHub repository where the action will be used.\n- An OpenAI API Key.\n- A GitHub Token with appropriate permissions (usually `${{ secrets.GITHUB_TOKEN }}` is sufficient).\n\n## Usage\n\n### Inputs\n\n- `openai_api_key` (required): Your OpenAI API key for generating PR information.\n- `github_token` (required): GitHub token for accessing the repository and making API calls.\n- `repository_owner` (required): GitHub repository owner (username or organization).\n- `repository` (required): GitHub repository name.\n- `branch` (required): Branch name to create the PR for.\n- `head` (required): Commit SHA for the head of the branch.\n\n### Example Workflow\n\nCreate a workflow file (e.g., `.github/workflows/pr-creator.yml`) in your repository:\n\n```yaml\nname: PR Creator\n\non:\n  push:\n    branches:\n      - '**'\n\njobs:\n  create_pr:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v3\n\n      - name: PR Creator with OpenAI\n        uses: Sinless777/PR-Creator@v1\n        with:\n          openai_api_key: ${{ secrets.OPENAI_API_KEY }}\n          github_token: ${{ secrets.GITHUB_TOKEN }}\n          repository_owner: ${{ github.repository_owner }}\n          repository: ${{ github.event.repository.name }}\n          branch: ${{ github.ref_name }}\n          head: ${{ github.sha }}\n```\n\n## Setup Instructions\n\n### OpenAI API Key\n\n1. Sign up at [OpenAI](https://beta.openai.com/signup/).\n2. Navigate to the [API Keys](https://platform.openai.com/account/api-keys) section.\n3. Create a new API key.\n4. Add the API key to your repository's secrets:\n   - Go to **Settings** \u003e **Secrets and variables** \u003e **Actions**.\n   - Click **New repository secret**.\n   - Name it `OPENAI_API_KEY` and paste your API key.\n\n### GitHub Token\n\n- The `${{ secrets.GITHUB_TOKEN }}` is automatically provided by GitHub Actions.\n- No additional setup is required unless custom permissions are needed.\n\n## Customization\n\nYou can customize the behavior by adjusting parameters in `main.py` or via action inputs:\n\n- **OpenAI Parameters**:\n  - `temperature`: Controls randomness (range 0 to 1). Lower values make output more deterministic.\n  - `max_tokens`: Maximum number of tokens to generate.\n- **Commit History Length**:\n  - Adjust the `limit` parameter in the `get_commit_history(limit=10)` function.\n\n## Error Handling\n\nThe script includes robust error handling:\n\n- **Input Validation**: Checks for missing environment variables and required inputs.\n- **API Rate Limits**: Implements retries with exponential backoff for API calls.\n- **Exception Handling**: Catches and logs exceptions without exposing sensitive information.\n\n## Development\n\n### Local Testing\n\n1. **Clone the Repository**:\n\n   ```bash\n   git clone https://github.com/Sinless777/PR-Creator.git\n   cd PR-Creator\n   ```\n\n2. **Install Dependencies**:\n\n   ```bash\n   pip install -r requirements.txt\n   ```\n\n3. **Set Environment Variables**:\n\n   ```bash\n   export OPENAI_API_KEY=your_openai_api_key\n   export GITHUB_TOKEN=your_github_token\n   export REPO_OWNER=your_repo_owner\n   export REPO_NAME=your_repo_name\n   export REPO_BRANCH=your_branch_name\n   export REPO_HEAD=your_commit_sha\n   ```\n\n4. **Run the Script**:\n\n   ```bash\n   python main.py\n   ```\n\n### Building the Docker Image\n\nIf you need to build the Docker image locally:\n\n```bash\ndocker build -t pr-creator .\n```\n\n### Running the Docker Container\n\n```bash\ndocker run --rm \\\n  -e OPENAI_API_KEY=your_openai_api_key \\\n  -e GITHUB_TOKEN=your_github_token \\\n  -e REPO_OWNER=your_repo_owner \\\n  -e REPO_NAME=your_repo_name \\\n  -e REPO_BRANCH=your_branch_name \\\n  -e REPO_HEAD=your_commit_sha \\\n  pr-creator\n```\n\n## Contributing\n\nContributions are welcome! Please follow these steps:\n\n1. Fork the repository.\n2. Create a new branch (`git checkout -b feature/your-feature`).\n3. Commit your changes (`git commit -m 'Add your feature'`).\n4. Push to the branch (`git push origin feature/your-feature`).\n5. Open a Pull Request.\n\n## License\n\nThis project is licensed under the [MIT License](LICENSE).\n\n## Acknowledgements\n\n- [OpenAI](https://openai.com/) for the GPT-3 language model.\n- [GitHub Actions](https://github.com/features/actions) for automation.\n- [commitlint](https://commitlint.js.org/) for commit message linting.\n- [Requests](https://requests.readthedocs.io/en/latest/) library for HTTP requests.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsinless777%2Fpr-creator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsinless777%2Fpr-creator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsinless777%2Fpr-creator/lists"}