Skip to main content

A Python library for creating GitHub issues programmatically using the GitHub REST API.

Project description

GitHub Issue Creator

A Python library for creating GitHub issues programmatically using the GitHub REST API.

Summary

Installation

First, install the library via pip (if it's not already installed):

pip install github-issue-creator

Usage

Import the necessary modules

from github_issue_creator import IssueCreator, Issue, IssueCreationError

Initialize IssueCreator

You'll need a GitHub Personal Access Token (PAT), the repository owner's username, and the repository name.

token = "your_github_token"
repo_owner = "your_github_username"
repo_name = "your_repository_name"

creator = IssueCreator(token, repo_owner, repo_name)

Create an Issue object

The Issue model should contain the issue details such as title, body, assignees, labels, etc.

issue = Issue(
    title="Sample Issue Title",
    body="This is the description of the issue.",
    assignees=["octocat"],  # Optional: list of GitHub usernames to assign
    labels=["bug", "help wanted"]  # Optional: list of labels
)

Create the issue on GitHub

Call the create method to post the issue.

try:
    creator.create(issue)
except IssueCreationError as e:
    print(f"Failed to create issue: {e}")
    if e.status_code:
        print(f"Status Code: {e.status_code}")
        print(f"Response: {e.response_text}")

If successful, it will return an IssueResponse object containing details of the created issue, including the issue URL, repository URL, issue ID, number, title, state, creation date, and the author's username.

For example, it may look like this:

IssueResponse(
    repository_url="https://github.com/fake_owner/fake_repo",
    issue_url="https://github.com/fake_owner/fake_repo/issues/1",
    issue_id=123456,
    issue_number=1,
    issue_title="Test",
    issue_state="open",
    created_at="2024-06-01T00:00:00Z",
    author="test_user"
)

Exceptions

  • IssueCreationError: Raised if the issue creation fails due to an HTTP error or a request exception.

Configuration Notes

  • Make sure your GitHub token has the correct permissions to create issues in the repository.
  • The Issue model should be defined based on the GitHub API's expected fields (check the library's models/issue.py for the schema).

Contributors

Thanks to the following people who have contributed to this project:

Feel free to open a pull request or report any issues you encounter. Your contributions are always welcome!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

github_issue_creator-0.2.0.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

github_issue_creator-0.2.0-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file github_issue_creator-0.2.0.tar.gz.

File metadata

  • Download URL: github_issue_creator-0.2.0.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for github_issue_creator-0.2.0.tar.gz
Algorithm Hash digest
SHA256 ecf93ca1f4da32aba175926c27b5a96a8cf7a4ac464a4ac659755ac754145e62
MD5 cf00066542876bdea42c8a5d84734a96
BLAKE2b-256 23503198cbe970c321c6a7e848c1fd87e24e14401f2b0378675aed03f7613e97

See more details on using hashes here.

File details

Details for the file github_issue_creator-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for github_issue_creator-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1bbdee3577452cfd5371acaead99a0fe07766a776e8a064084996245ea20c8ff
MD5 26120f3135cccfaf0d78d948c50f2995
BLAKE2b-256 aea7b820ddd42ff6e8e5f3e15d42858d245df6c1c6ed5989d00fd4ae58cee4e1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page