---
title: "GitHub Connector"
description: "คู่มือการผสานรวม GitHub ฉบับสมบูรณ์สำหรับการซิงค์เหตุการณ์ repository ปัญหา pull requests และกิจกรรมนักพัฒนากับ Brevo ผ่าน Tajo"
url: https://tajo.io/th/docs/connectors/custom/github/
markdown: https://tajo.io/th/docs/connectors/custom/github.md
lang: th-TH
robots: noindex
---

ขอสิทธิ์ใช้งานล่วงหน้า

กรอกชื่อและที่อยู่อีเมลที่ทำงานของคุณ เราจะส่งลิงก์เพื่อยืนยันคำขอเข้าใช้งาน Tajo ทางอีเมล

# GitHub Connector

สถานะตัวเชื่อม: วางแผนไว้ ยังไม่ได้สร้าง ปัจจุบัน Tajo ยังไม่ได้ใช้งานตัวเชื่อมนี้

| ฟิลด์ต้นทาง | ฟิลด์ปลายทาง | ค่าตัวอย่าง |
| --- | --- | --- |
| `record.id` | `source_id` | `record_1042` |
| `record.updated_at` | `updated_at` | `2026-10-18T08:00:00Z` |
| `record.value` | `value` | `sample_value` |

เชื่อมต่อ GitHub repositories กับ Brevo สำหรับการติดตามการมีส่วนร่วมของนักพัฒนา เวิร์กโฟลว์การแจ้งเตือน release และการตรวจสอบกิจกรรมชุมชนผ่าน Tajo

## ภาพรวม

| คุณสมบัติ | ค่า |
| --- | --- |
| **แพลตฟอร์ม** | GitHub |
| **หมวดหมู่** | แบบกำหนดเอง |
| **ความซับซ้อนในการตั้งค่า** | ปานกลาง |
| **การผสานรวมอย่างเป็นทางการ** | ไม่ |
| **ข้อมูลที่ซิงค์** | เหตุการณ์ ผู้ใช้ Repositories |
| **ประเภท API** | REST API, GraphQL API |
| **การยืนยันตัวตน** | GitHub App / Personal Access Token / OAuth 2.0 |
| **Base URL** | `https://api.github.com` |
| **เวอร์ชัน API** | `2022-11-28` (header-based versioning) |

## ฟีเจอร์

- **การติดตามปัญหาและ PR** - ซิงค์เหตุการณ์ปัญหาและ pull request กับไทม์ไลน์ผู้ติดต่อ Brevo
- **การแจ้งเตือน Release** - ทริกเกอร์แคมเปญ Brevo เมื่อมี repository release ใหม่
- **การซิงค์ผู้ร่วมพัฒนา** - แมปผู้ร่วมพัฒนา GitHub กับผู้ติดต่อ Brevo สำหรับการมีส่วนร่วมของชุมชน
- **การติดตาม Star และ Fork** - ตรวจสอบตัวชี้วัดความนิยมของ repository
- **การส่งต่อเหตุการณ์ Webhook** - ส่งต่อเหตุการณ์ GitHub ไปยังระบบอัตโนมัติ Brevo
- **Repository catalog** - ซิงค์ metadata ของ repository เป็นรายการ catalog ของ Brevo

## ข้อกำหนดเบื้องต้น

ก่อนเริ่มต้น ตรวจสอบให้แน่ใจว่าคุณมี:

1. บัญชี GitHub ที่มีสิทธิ์เข้าถึง repositories เป้าหมาย
2. GitHub App หรือ Personal Access Token (แนะนำแบบ fine-grained)
3. สิทธิ์ผู้ดูแลระบบสำหรับ repositories สำหรับการกำหนดค่า webhook
4. บัญชี Brevo ที่มีสิทธิ์เข้าถึง API
5. บัญชี Tajo ที่มีการสมัครสมาชิกที่ใช้งานอยู่

## การยืนยันตัวตน

GitHub รองรับวิธีการยืนยันตัวตนหลายแบบ Tajo แนะนำให้ใช้ GitHub Apps สำหรับการเข้าถึงระดับองค์กร

### ตัวเลือกที่ 1: GitHub App (แนะนำ)

1. ไปที่ **Settings** > **Developer settings** > **GitHub Apps**
2. คลิก **New GitHub App**
3. กำหนดค่า app ด้วยสิทธิ์เหล่านี้:

```
Repository permissions:
  Issues: Read
  Pull requests: Read
  Contents: Read
  Metadata: Read

Organization permissions:
  Members: Read

Subscribe to events:
  Issues
  Pull request
  Push
  Release
  Star
  Fork
```

### ตัวเลือกที่ 2: Fine-Grained Personal Access Token

1. ไปที่ **Settings** > **Developer settings** > **Personal access tokens** > **Fine-grained tokens**
2. คลิก **Generate new token**
3. เลือก repositories เป้าหมาย
4. ให้สิทธิ์เหล่านี้:

```
Repository access: Selected repositories
Permissions:
  Issues: Read-only
  Pull requests: Read-only
  Contents: Read-only
  Metadata: Read-only
```

ความปลอดภัย Token

Fine-grained tokens มีวันหมดอายุ ตั้งค่าการหมุนเวียน token ก่อนหมดอายุ GitHub App installation tokens รีเฟรชโดยอัตโนมัติและเป็นที่นิยมสำหรับการใช้งานจริง

### เชื่อมต่อกับ Tajo

```bash
# Using GitHub App
tajo connectors install github \
  --app-id $GITHUB_APP_ID \
  --private-key-path ./github-app-key.pem \
  --installation-id $GITHUB_INSTALLATION_ID

# Using Personal Access Token
tajo connectors install github \
  --token $GITHUB_TOKEN
```

## การกำหนดค่า

### การตั้งค่าพื้นฐาน

```yaml
connectors:
  github:
    enabled: true
    auth_type: "github_app"  # or "token"

    repositories:
      - owner/repo-1
      - owner/repo-2

    sync:
      issues: true
      pull_requests: true
      releases: true
      contributors: true
      stars: true

    lists:
      contributors: 20
      stargazers: 21
```

### การแมปฟิลด์

แมปข้อมูลผู้ใช้ GitHub กับแอตทริบิวต์ผู้ติดต่อ Brevo:

```yaml
field_mapping:
  # Standard fields
  login: GITHUB_USERNAME
  email: email
  name: FIRSTNAME

  # Developer metrics
  contributions: GITHUB_CONTRIBUTIONS
  repositories_count: GITHUB_REPOS
  followers: GITHUB_FOLLOWERS
  created_at: GITHUB_JOINED

  # Custom attributes
  company: COMPANY
  location: LOCATION
  bio: GITHUB_BIO
```

## API Endpoints

Tajo ผสานรวมกับ GitHub REST API endpoints ต่อไปนี้:

| Endpoint | เมธอด | จุดประสงค์ |
| --- | --- | --- |
| `/repos/{owner}/{repo}/issues` | GET | แสดงรายการปัญหาของ repository |
| `/repos/{owner}/{repo}/pulls` | GET | แสดงรายการ pull requests |
| `/repos/{owner}/{repo}/releases` | GET | แสดงรายการ releases |
| `/repos/{owner}/{repo}/contributors` | GET | แสดงรายการผู้ร่วมพัฒนา |
| `/repos/{owner}/{repo}/stargazers` | GET | แสดงรายการผู้ติดดาว |
| `/repos/{owner}/{repo}/forks` | GET | แสดงรายการ forks |
| `/repos/{owner}/{repo}/events` | GET | แสดงรายการเหตุการณ์ repository |
| `/users/{username}` | GET | ดูโปรไฟล์ผู้ใช้ |
| `/orgs/{org}/members` | GET | แสดงรายการสมาชิกองค์กร |
| `/repos/{owner}/{repo}/hooks` | POST | สร้าง webhook |

## ตัวอย่างโค้ด

### เริ่มต้น Connector

```javascript
import { TajoClient } from '@tajo/sdk';

const tajo = new TajoClient({
  apiKey: process.env.TAJO_API_KEY,
  brevoApiKey: process.env.BREVO_API_KEY
});

await tajo.connectors.connect('github', {
  appId: process.env.GITHUB_APP_ID,
  privateKey: process.env.GITHUB_PRIVATE_KEY,
  installationId: process.env.GITHUB_INSTALLATION_ID
});
```

### ซิงค์ผู้ร่วมพัฒนากับ Brevo

```javascript
await tajo.connectors.sync('github', {
  type: 'full',
  resources: ['contributors'],
  repositories: ['owner/repo-1', 'owner/repo-2']
});

const status = await tajo.connectors.status('github');
console.log(status);
// {
//   connected: true,
//   lastSync: '2024-03-15T11:00:00Z',
//   contributorsCount: 245,
//   issuesTracked: 1890,
//   releasesTracked: 34
// }
```

### จัดการเหตุการณ์ Webhook

```javascript
app.post('/webhooks/github', async (req, res) => {
  const signature = req.get('X-Hub-Signature-256');
  const event = req.get('X-GitHub-Event');

  // Verify webhook signature
  if (!verifyGitHubSignature(req.body, signature)) {
    return res.status(401).send('Unauthorized');
  }

  await tajo.connectors.handleWebhook('github', {
    event,
    payload: req.body
  });

  res.status(200).send('OK');
});
```

### ทริกเกอร์แคมเปญ Release

```javascript
// Listen for new releases and trigger Brevo campaign
tajo.connectors.on('github', 'release.published', async (event) => {
  await tajo.campaigns.trigger('release-announcement', {
    listId: 21,
    params: {
      version: event.release.tag_name,
      release_notes: event.release.body,
      download_url: event.release.html_url
    }
  });
});
```

## ขีดจำกัดอัตรา

GitHub ใช้ขีดจำกัดอัตราตามวิธีการยืนยันตัวตน:

| การยืนยันตัวตน | ขีดจำกัดอัตราหลัก | Search API |
| --- | --- | --- |
| **ไม่ยืนยันตัวตน** | 60 คำขอ/ชั่วโมง | 10 คำขอ/นาที |
| **Personal Access Token** | 5,000 คำขอ/ชั่วโมง | 30 คำขอ/นาที |
| **GitHub App (installation)** | 5,000 คำขอ/ชั่วโมง | 30 คำขอ/นาที |
| **GitHub App (user-to-server)** | 5,000 คำขอ/ชั่วโมง | 30 คำขอ/นาที |

Conditional Requests

Tajo ใช้ conditional requests (headers `If-None-Match` / `If-Modified-Since`) เพื่อลดการใช้ API การตอบสนองที่มี `304 Not Modified` ไม่นับต่อขีดจำกัดอัตรา

ขีดจำกัดเพิ่มเติม:

- **ขีดจำกัดอัตราทุติยภูมิ**: ไม่เกิน 100 คำขอพร้อมกัน ไม่เกิน 900 points ต่อนาทีสำหรับ REST API endpoints
- **GraphQL**: 5,000 points ต่อชั่วโมง (ต้นทุน query แตกต่างกันตามความซับซ้อน)

## การแก้ไขปัญหา

### ปัญหาทั่วไป

| ปัญหา | สาเหตุ | วิธีแก้ |
| --- | --- | --- |
| 401 Unauthorized | Token หมดอายุหรือข้อมูลรับรองไม่ถูกต้อง | สร้าง token ใหม่หรือติดตั้ง GitHub App ใหม่ |
| 403 Forbidden | สิทธิ์ไม่เพียงพอ | ตรวจสอบ scope ของ token หรือสิทธิ์ App |
| 404 Not Found | repo ส่วนตัวไม่มีสิทธิ์เข้าถึง | ให้สิทธิ์เข้าถึง repository กับ token หรือ App |
| เกินขีดจำกัดอัตรา | การเรียก API มากเกินไป | เปิดใช้ conditional requests และลดความถี่การซิงค์ |
| ไม่ได้รับ Webhooks | URL ไม่ถูกต้องหรือไฟร์วอลล์ | ตรวจสอบว่า URL webhook เข้าถึงได้สาธารณะ |

### โหมด Debug

```yaml
connectors:
  github:
    debug: true
    log_level: verbose
    log_webhooks: true
```

### ทดสอบการเชื่อมต่อ

```bash
tajo connectors test github
# ✓ API authentication successful
# ✓ Repository access verified
# ✓ Issue data readable
# ✓ Webhook delivery active
# ✓ Rate limit healthy (4,850/5,000 remaining)
```

## แนวทางปฏิบัติที่ดีที่สุด

1. **ใช้ GitHub Apps แทน PATs** - GitHub Apps ให้สิทธิ์แบบละเอียดและ tokens ที่รีเฟรชอัตโนมัติ
2. **เปิดใช้ webhook secrets** - ตรวจสอบลายเซ็น webhook เสมอด้วย HMAC-SHA256
3. **ใช้ conditional requests** - ใช้ ETags เพื่อหลีกเลี่ยงการสิ้นเปลือง quota ขีดจำกัดอัตรา
4. **Paginate การตอบสนองขนาดใหญ่** - GitHub ส่งคืนสูงสุด 100 รายการต่อหน้า วนซ้ำด้วย `Link` headers
5. **ซิงค์ระหว่างกิจกรรมน้อย** - กำหนดการซิงค์แบบเต็มนอกชั่วโมงการพัฒนาสูงสุด
6. **ตรวจสอบ headers ขีดจำกัดอัตรา** - ตรวจสอบ `X-RateLimit-Remaining` เพื่อลดความเร็วเชิงรุก

## ความปลอดภัย

- **การยืนยันตัวตน GitHub App** - JWT ตาม RSA key พร้อม installation tokens อายุสั้น
- **ลายเซ็น Webhook** - การตรวจสอบลายเซ็น HMAC-SHA256 บน webhook payloads ทั้งหมด
- **Fine-Grained Tokens** - กำหนดขอบเขตกับ repositories และสิทธิ์เฉพาะ
- **HTTPS เท่านั้น** - การสื่อสาร API ทั้งหมดเข้ารหัสผ่าน TLS 1.2+
- **การจัดเก็บที่เข้ารหัส** - Private keys และ tokens เข้ารหัสที่เก็บใน Tajo
- **การหมดอายุ Token** - Fine-grained tokens หมดอายุโดยอัตโนมัติ ตั้งค่าการแจ้งเตือนการหมุนเวียน

## แหล่งข้อมูลที่เกี่ยวข้อง

- [Jira Connector](https://tajo.io/th/docs/connectors/custom/jira)
- [Linear Connector](https://tajo.io/th/docs/connectors/custom/linear)
- [Notion Connector](https://tajo.io/th/docs/connectors/custom/notion)
- [Brevo Contacts API](https://tajo.io/th/docs/contact-management)
