Skip to main content

A Python module for managing GitHub Projects (v2), issues, labels, and milestones

Project description

GitHub Project Manager

Tests PyPI version Python Versions License: MIT codecov

A Python library for managing GitHub Projects (v2), issues, labels, and milestones.

Features

  • Create and manage GitHub Projects (v2)
  • Add issues to projects
  • Automatically update issue descriptions when they change
  • Manage project fields and status options
  • Create and update labels across multiple repositories
  • Create and update milestones across multiple repositories

Installation

pip install github-project-manager

Requirements

This library depends on:

  • Python 3.10+
  • requests >= 2.25.0
  • python-dotenv >= 0.15.0

Configuration

You need to set the following environment variables:

  • GITHUB_TOKEN: Your GitHub personal access token with appropriate permissions
  • GITHUB_ORG: Your GitHub organization name

You can also use a .env file:

GITHUB_TOKEN=your_github_token
GITHUB_ORG=your_org_name

Usage Examples

Initialize the Manager

from github_project_manager import GitHubProjectManager

# Initialize the manager
manager = GitHubProjectManager()

# Initialize with an existing project
manager = GitHubProjectManager("My Existing Project")

# If you need to change the logging level
import logging
logging.getLogger("ghpm").setLevel(logging.DEBUG)

Create a Project and Add Issues

# Create a new project (or use an existing one with the same name)
project_id = manager.create_project("My Project")

# Create an issue (or use an existing one with the same title)
# Method 1: Create issue and add to project separately
issue_node_id = manager.create_issue("my-repo", "Issue Title", "Issue description")
manager.add_issue_to_project(issue_node_id)

# Method 2: Create issue and add to project in one step
issue_node_id = manager.create_issue(
    "my-repo",
    "Issue Title",
    "Issue description",
    add_to_project=True
)

# Method 3: Create issue with labels
issue_node_id = manager.create_issue(
    "my-repo",
    "Issue Title",
    "Issue description",
    add_to_project=True,
    labels=["bug", "high-priority"]
)

Automatic Issue Description Updates

The library will automatically update the description of an existing issue if it has changed:

# If an issue with this title already exists but with a different description,
# the description will be updated automatically
issue_node_id = manager.create_issue(
    "my-repo",
    "Existing Issue Title",
    "Updated description"
)

Manage Project Status Options

from github_project_manager import StatusOption

# Define status options
status_options = [
    StatusOption("To Do", "RED"),
    StatusOption("In Progress", "YELLOW"),
    StatusOption("Done", "GREEN", "Completed work"),
]

# Update the project's status field
manager.update_status_options(status_options)

# Replace all existing options with new ones
manager.update_status_options(status_options, preserve_existing=False)

Manage Labels Across Repositories

from github_project_manager import IssueLabel

# Create a single label
label = IssueLabel("bug", "FF0000", "Something isn't working")

# Create in a single repository
manager.create_labels("my-repo", label)

# Create in multiple repositories
manager.create_labels(["repo1", "repo2"], label)

# Create multiple labels in multiple repositories
labels = [
    IssueLabel("bug", "FF0000", "Something isn't working"),
    IssueLabel("enhancement", "0000FF", "New feature or request"),
]
manager.create_labels(["repo1", "repo2"], labels)

Manage Milestones Across Repositories

from github_project_manager import IssueMilestone

# Create a milestone with a due date
milestone = IssueMilestone(
    "v1.0",
    "First stable release",
    "2023-12-31T23:59:59Z"
)

# Create in multiple repositories
manager.create_milestones(
    ["repo1", "repo2"],
    milestone
)

License

MIT

Contributing

We welcome contributions! Please see CONTRIBUTING.md for details on how to set up the development environment, run tests, and submit contributions.

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_project_manager-0.2.0.tar.gz (15.2 kB view details)

Uploaded Source

Built Distribution

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

github_project_manager-0.2.0-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: github_project_manager-0.2.0.tar.gz
  • Upload date:
  • Size: 15.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for github_project_manager-0.2.0.tar.gz
Algorithm Hash digest
SHA256 da8854aedf165f618a7cd7bff6461b0365311a9cf6750ca2f1fb1d6257fed6e6
MD5 dbb6a962657d75135567eb9baee2a338
BLAKE2b-256 a6c399010fbe54aa1847a7aaa93fb551ca0cd8520aa77cc02f124dc57e0ccf26

See more details on using hashes here.

Provenance

The following attestation bundles were made for github_project_manager-0.2.0.tar.gz:

Publisher: publish.yml on ezrahill/github-project-manager

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for github_project_manager-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 21ffc812f6dfb86f6c6761964a389702e1831f0e3db00d66f6bcf018c529b6b1
MD5 0792ff25fff3550524d5be568175eca0
BLAKE2b-256 bfa777375f26ffee87f0f52b7ec18f94a5b9cdf33792302945cddc4ac6ae7fbd

See more details on using hashes here.

Provenance

The following attestation bundles were made for github_project_manager-0.2.0-py3-none-any.whl:

Publisher: publish.yml on ezrahill/github-project-manager

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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