Github

Github automation and integration for streamlined code collaboration and version control

Github is a community skill for automating GitHub workflows and repository management, covering issue tracking, pull request automation, repository configuration, Actions workflow setup, and team collaboration management for software development projects.

What Is This?

Overview

Github provides tools for programmatic interaction with GitHub repositories and organizational workflows. It covers issue tracking that creates, labels, assigns, and queries issues using the GitHub API for structured bug and feature request management, pull request automation that opens, reviews, and merges pull requests with configurable branch protection and review requirements, repository configuration that manages settings for branch policies, merge strategies, and access permissions, Actions workflow setup that creates and configures CI/CD pipelines for automated testing and deployment, and team collaboration that manages contributor permissions, code owners, and review assignment rules. The skill enables developers to automate repository operations and enforce consistent development workflows.

Who Should Use This

This skill serves developers automating repository management tasks, DevOps engineers configuring CI/CD pipelines with GitHub Actions, and team leads managing contributor workflows and branch protection policies.

Why Use It?

Problems It Solves

Manual issue management becomes unscalable as projects grow with hundreds of open issues requiring triage. Pull request workflows lack consistency when review policies are not enforced through automation. Repository settings drift across multiple projects when configured manually through the web interface. CI/CD pipeline setup involves repetitive YAML authoring that could be templated and generated.

Core Highlights

Issue manager creates, queries, and bulk updates issues with label and milestone filtering. PR automator opens pull requests, assigns reviewers, and enforces merge requirements. Repo configurator applies branch protection rules and merge settings programmatically. Workflow generator creates GitHub Actions YAML for common CI/CD patterns.

How to Use It?

Basic Usage

import requests

class GitHubClient:
  BASE = (
    'https://api.github'
    '.com')

  def __init__(
    self,
    token: str
  ):
    self.headers = {
      'Authorization':
        f'Bearer {token}',
      'Accept': 'application'
        '/vnd.github.v3'
        '+json'}

  def list_issues(
    self,
    owner: str,
    repo: str,
    labels: str = None
  ) -> list[dict]:
    params = {
      'state': 'open'}
    if labels:
      params['labels'] = (
        labels)
    resp = requests.get(
      f'{self.BASE}/repos'
      f'/{owner}/{repo}'
      f'/issues',
      headers=self.headers,
      params=params)
    resp.raise_for_status()
    return resp.json()

  def create_issue(
    self,
    owner: str,
    repo: str,
    title: str,
    body: str,
    labels: list = None
  ) -> dict:
    data = {
      'title': title,
      'body': body}
    if labels:
      data['labels'] = (
        labels)
    resp = requests.post(
      f'{self.BASE}/repos'
      f'/{owner}/{repo}'
      f'/issues',
      headers=self.headers,
      json=data)
    resp.raise_for_status()
    return resp.json()

Real-World Examples

class PRManager:
  def __init__(
    self,
    client: GitHubClient
  ):
    self.client = client

  def create_pr(
    self,
    owner: str,
    repo: str,
    head: str,
    base: str,
    title: str,
    body: str
  ) -> dict:
    data = {
      'title': title,
      'body': body,
      'head': head,
      'base': base}
    resp = requests.post(
      f'{self.client.BASE}'
      f'/repos/{owner}'
      f'/{repo}/pulls',
      headers=self.client
        .headers,
      json=data)
    resp.raise_for_status()
    return resp.json()

  def request_review(
    self,
    owner: str,
    repo: str,
    pr_number: int,
    reviewers: list[str]
  ) -> dict:
    resp = requests.post(
      f'{self.client.BASE}'
      f'/repos/{owner}'
      f'/{repo}/pulls'
      f'/{pr_number}'
      f'/requested'
      f'_reviewers',
      headers=self.client
        .headers,
      json={'reviewers':
        reviewers})
    resp.raise_for_status()
    return resp.json()

Advanced Tips

Use GitHub Apps instead of personal access tokens for automation that runs across multiple repositories since Apps provide finer-grained permissions and higher rate limits. Implement webhook handlers to trigger automated workflows in response to events rather than polling the API. Use GraphQL API for complex queries that need data from multiple related resources in a single request.

When to Use It?

Use Cases

Automate issue triage by labeling and assigning new issues based on content keywords. Set up pull request workflows that enforce review requirements and automated testing before merge. Configure repository settings across multiple projects for consistent branch protection.

Related Topics

GitHub API, repository management, CI/CD, GitHub Actions, pull request automation, issue tracking, and developer workflows.

Important Notes

Requirements

GitHub personal access token or GitHub App credentials with appropriate scopes. Python requests library for API communication. Repository admin access for configuring branch protection and repository settings.

Usage Recommendations

Do: use fine-grained personal access tokens scoped to specific repositories rather than classic tokens with broad access. Handle rate limiting by checking response headers and backing off when approaching limits. Store tokens securely in environment variables or secret managers.

Don't: embed API tokens directly in source code or commit them to repositories. Ignore pagination when listing issues or pull requests since the API returns at most 100 items per page. Make destructive API calls without dry-run verification in production repositories.

Limitations

GitHub API rate limits allow 5000 requests per hour for authenticated users which constrains high-volume automation. Some repository settings require organization admin permissions that may not be available to all users. Webhook delivery is not guaranteed and automation should handle missed events gracefully.