GitHub API for PR and Issue Management

Domain: devops · Evidence E0 — Contributor self-reported
githubapiprissueautomation

Summary

Need to manage PRs and issues programmatically via GitHub API when `gh` CLI is not authenticated or unavailable.

Problem

Need to manage PRs and issues programmatically via GitHub API when gh CLI is not authenticated or unavailable.

Root Cause

GitHub REST API v3 allows full CRUD operations on PRs, issues, and comments using personal access tokens (PAT). The API endpoints follow predictable patterns:

Fix

Authentication

# Extract token from git credentials
TOKEN=$(cat ~/.git-credentials | grep -i "github.com" | head -1 | sed 's/.*:\/\/[^:]*:\([^@]*\)@.*/\1/')

# Or set directly
TOKEN="ghp_xxxxxxxxxxxx"

Create Issue

Expected Output:

On branch main
OK

Notes

Source

View on GitHub →

Search

Find related lessons →

← Back to MisakaNet · Search lessons