---
name: github-auth
description: Authenticate to GitHub using the organization's GitHub App. Use when you need to create PRs, push code, or perform GitHub operations that require authentication.
---

# GitHub Authentication

Use this skill for GitHub authentication when gh CLI needs a token.

## Quick Usage

```bash
# Get token (auto-configured from environment)
export GH_TOKEN="$(~/github/data-service-infra-ai-configurations/skills/team-common/github-auth/scripts/github-auth.sh)"

# Or set token for gh
gh auth login --with-token <<< "$GH_TOKEN"

# Now you can run gh commands
gh pr create --title "..." --body "..."
git push origin main
```

## How It Works

1. Reads GitHub App credentials from environment (`~/.bashrc`)
2. Generates a JWT using the private key
3. Exchanges JWT for an installation access token
4. Returns the token for use with gh CLI or git

## Environment Variables

The script reads from `~/.bashrc`:
- `GITHUB_APP_ID` (default: 3002333)
- `GITHUB_APP_PRIVATE_KEY_PATH` (default: ~/.github/data-service-code-assist.pem)
- `GITHUB_APP_INSTALLATION_ID` (default: 113867057)

## Requirements

- Python3 with `pyjwt` module: `pip install pyjwt cryptography`
- Access to the private key file

## Example Workflow

```bash
# 1. Get token
export GH_TOKEN="$(~/github/data-service-infra-ai-configurations/skills/team-common/github-auth/scripts/github-auth.sh)"

# 2. Configure gh
gh auth login --with-token <<< "$GH_TOKEN"

# 3. Verify
gh auth status

# 4. Create PR
cd ~/github/data-service-infra-ai-configurations
git push origin my-branch
gh pr create --title "My PR" --body "Description"
```
