Skip to main content

Lightweight and easy-to-use Python SDK for seamless GitHub REST API integration, automation of GitHub Actions workflows, environment variable management, and OAuth authentication.

Project description

GitHub Client SDK — Python Library for GitHub API Automation

PyPI version Python Version License: MIT Build Status Downloads

Overview

GitHub Client SDK is a powerful and easy-to-use Python library designed to simplify interaction with the GitHub REST API v3 and automate GitHub Actions workflows, environment variables, and repository management tasks.

This SDK provides a clean interface for developers, DevOps engineers, and automation specialists to seamlessly integrate GitHub operations into Python projects and CI/CD pipelines.

Key Features

  • 🔄 GitHub Actions Workflow Management: Create, list, and delete workflows effortlessly via Python.
  • 🔐 OAuth Authentication Support: Securely authenticate using OAuth tokens.
  • ⚙️ Environment Variable Handling: Create, update, and delete environment variables for GitHub workflows.
  • 🧩 Lightweight & Extensible: Minimal dependencies and easy to extend for custom needs.
  • 🚀 Supports Python 3.9+: Compatible with modern Python environments.
  • 💻 Interactive CLI: Built-in command-line interface for easy interaction.

Installation

Install the latest version of GitHub Client SDK directly from PyPI:

pip install github-client-sdk

Or clone the repository and install dependencies:

git clone https://github.com/azimhossaintuhin/github-client-sdk.git
cd github-client-sdk
pip install -r requirements.txt

Quick Start Guide

Authentication

from github_client_sdk.auth import AuthClient
import os

# Initialize the auth client
auth = AuthClient(
    client_id=os.getenv("CLIENT_ID"),
    client_secret=os.getenv("CLIENT_SECRET"),
    redirect_uri="http://localhost:8000/callback",
    scope=["repo", "user:email", "workflow"]
)

# Get authentication URL
auth_url = auth.get_auth_url()
print(f"Visit this URL to authorize: {auth_url}")

# Get access token
code = input("Enter the authorization code: ")
access_token = auth.get_access_token(code)

# Get user information
user_info = auth.get_user_info(access_token)
print(user_info)

Managing Workflows

from github_client_sdk.client import GitHubClient
from github_client_sdk.workflow import Workflow

# Initialize the client
client = GitHubClient(token="your_oauth_token")

# Create workflow instance
workflow = Workflow(client, "username", "repository_name")

# Create a new workflow
workflow_name = "new-workflow"
workflow_path = "path/to/workflow.yaml"
response = workflow.create_workflow(workflow_name, workflow_path)
print(f"Workflow creation response: {response}")

# List workflows
workflows = workflow.get_workflows()
print(workflows)

# Delete workflow
workflow.delete_workflow("workflow_id")

Managing Environment Variables

from github_client_sdk.variables import Variables

# Initialize variables client
variables = Variables(client, "username", "repository_name")

# Get all variables
all_variables = variables.get_variables()
print(all_variables)

# Create a new variable
variables.create_variable("TEST_VARIABLE", "TEST_VALUE")

# Update an existing variable
variables.update_variable("TEST_VARIABLE", "NEW_VALUE")

# Get a specific variable
variable = variables.get_variable("TEST_VARIABLE")
print(variable)

# Delete a variable
variables.delete_variable("TEST_VARIABLE")

Using the CLI

The SDK comes with a built-in CLI for easy interaction:

# Start the interactive shell
github-client-shell

# Available commands in the shell:
# 1. authenticate     : Authenticate with GitHub
# 2. get-user-info   : Fetch and display user info
# 3. set-env-variable: Set environment variables
# 4. get-env-variables: Get environment variables
# 5. logout          : Logout from GitHub
# 6. clear           : Clear the screen
# 7. exit            : Exit the shell

Environment Variables

The SDK requires the following environment variables to be set:

  • CLIENT_ID: Your GitHub OAuth App client ID
  • CLIENT_SECRET: Your GitHub OAuth App client secret

Contributing

Contributions are welcome! Please read the CONTRIBUTING.md guide before submitting a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Related Links


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_client_sdk-1.1.2.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

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

github_client_sdk-1.1.2-py3-none-any.whl (14.0 kB view details)

Uploaded Python 3

File details

Details for the file github_client_sdk-1.1.2.tar.gz.

File metadata

  • Download URL: github_client_sdk-1.1.2.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.12.3 Linux/6.11.0-26-generic

File hashes

Hashes for github_client_sdk-1.1.2.tar.gz
Algorithm Hash digest
SHA256 e17e70898ac3e3d168a983b8bf2944095942198094cd055f1a2c6bb274f758e5
MD5 35108f517157a352bcb7369f1bbaf780
BLAKE2b-256 555aa35227cf1692c7086abcf24da3731c1f99b73e06cb09588687aa8a019380

See more details on using hashes here.

File details

Details for the file github_client_sdk-1.1.2-py3-none-any.whl.

File metadata

  • Download URL: github_client_sdk-1.1.2-py3-none-any.whl
  • Upload date:
  • Size: 14.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.12.3 Linux/6.11.0-26-generic

File hashes

Hashes for github_client_sdk-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4bc6defb11c6635eebad48fe7ab5b16172e5763de554a91c308af1fab42a0fb3
MD5 d61879a12dd2ba546ec28c10b7c135b5
BLAKE2b-256 b87f311cd90b7ee845c2be1f505f626226f99f49b4f311e975812ceefdf90416

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