GitHub कनेक्टर
developer engagement tracking, release notification workflows, और community activity monitoring के लिए अपने GitHub repositories को Tajo के माध्यम से Brevo से कनेक्ट करें।
अवलोकन
| Property | Value |
|---|---|
| Platform | GitHub |
| Category | Custom |
| Setup Complexity | Moderate |
| Official Integration | No |
| Data Synced | Events, Users, Repositories |
| API Type | REST API, GraphQL API |
| Authentication | GitHub App / Personal Access Token / OAuth 2.0 |
| Base URL | https://api.github.com |
| API Version | 2022-11-28 (header-based versioning) |
विशेषताएं
- Issue और PR tracking - issue और pull request events को Brevo contact timelines में sync करें
- Release notifications - नए repository releases पर Brevo campaigns trigger करें
- Contributor sync - community engagement के लिए GitHub contributors को Brevo contacts से map करें
- Star और fork tracking - repository popularity metrics monitor करें
- Webhook event forwarding - GitHub events को Brevo automations में forward करें
- Repository catalog - repository metadata को Brevo catalog items के रूप में sync करें
पूर्वावश्यकताएं
शुरू करने से पहले, सुनिश्चित करें कि आपके पास हैं:
- target repositories तक access वाला एक GitHub account
- एक GitHub App या Personal Access Token (fine-grained अनुशंसित)
- webhook configuration के लिए repositories का admin access
- API access वाला एक Brevo account
- सक्रिय subscription वाला एक Tajo account
प्रमाणीकरण
GitHub कई authentication methods को support करता है। Tajo organization-level access के लिए GitHub Apps का उपयोग करने की अनुशंसा करता है।
विकल्प 1: GitHub App (अनुशंसित)
- Settings > Developer settings > GitHub Apps पर जाएं
- New GitHub App पर क्लिक करें
- इन permissions के साथ 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
- Settings > Developer settings > Personal access tokens > Fine-grained tokens पर जाएं
- Generate new token पर क्लिक करें
- target repositories चुनें
- ये permissions दें:
Repository access: Selected repositoriesPermissions: Issues: Read-only Pull requests: Read-only Contents: Read-only Metadata: Read-onlyToken Security
Fine-grained tokens की expiration dates होती हैं। expiry से पहले token rotation सेट करें। GitHub App installation tokens auto-refresh होते हैं और production use के लिए बेहतर हैं।
Tajo से कनेक्ट करना
# GitHub App का उपयोगtajo connectors install github \ --app-id $GITHUB_APP_ID \ --private-key-path ./github-app-key.pem \ --installation-id $GITHUB_INSTALLATION_ID
# Personal Access Token का उपयोगtajo connectors install github \ --token $GITHUB_TOKENकॉन्फ़िगरेशन
बेसिक सेटअप
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: 21Field Mapping
GitHub user data को Brevo contact attributes से map करें:
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_BIOAPI Endpoints
Tajo निम्नलिखित GitHub REST API endpoints के साथ integrate करता है:
| Endpoint | Method | उद्देश्य |
|---|---|---|
/repos/{owner}/{repo}/issues | GET | repository issues list करें |
/repos/{owner}/{repo}/pulls | GET | pull requests list करें |
/repos/{owner}/{repo}/releases | GET | releases list करें |
/repos/{owner}/{repo}/contributors | GET | contributors list करें |
/repos/{owner}/{repo}/stargazers | GET | stargazers list करें |
/repos/{owner}/{repo}/forks | GET | forks list करें |
/repos/{owner}/{repo}/events | GET | repository events list करें |
/users/{username} | GET | user profile प्राप्त करें |
/orgs/{org}/members | GET | organization members list करें |
/repos/{owner}/{repo}/hooks | POST | webhook बनाएं |
कोड उदाहरण
कनेक्टर शुरू करें
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});Contributors को Brevo से Sync करें
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 Events हैंडल करें
app.post('/webhooks/github', async (req, res) => { const signature = req.get('X-Hub-Signature-256'); const event = req.get('X-GitHub-Event');
// 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 Campaign Trigger करें
// नए releases सुनें और Brevo campaign trigger करें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 } });});Rate Limits
GitHub authentication method के आधार पर rate limits लागू करता है:
| Authentication | Primary Rate Limit | Search API |
|---|---|---|
| Unauthenticated | 60 requests/hour | 10 requests/minute |
| Personal Access Token | 5,000 requests/hour | 30 requests/minute |
| GitHub App (installation) | 5,000 requests/hour | 30 requests/minute |
| GitHub App (user-to-server) | 5,000 requests/hour | 30 requests/minute |
Conditional Requests
Tajo API consumption कम करने के लिए conditional requests (If-None-Match / If-Modified-Since headers) का उपयोग करता है। 304 Not Modified वाले responses rate limits में नहीं गिने जाते।
अतिरिक्त limits:
- Secondary rate limits: 100 से अधिक concurrent requests नहीं। REST API endpoints के लिए प्रति minute 900 points से अधिक नहीं।
- GraphQL: 5,000 points प्रति घंटा (query cost complexity के अनुसार भिन्न होती है)।
समस्या निवारण
सामान्य समस्याएं
| समस्या | कारण | समाधान |
|---|---|---|
| 401 Unauthorized | Expired token या गलत credentials | token पुनः generate करें या GitHub App पुनः install करें |
| 403 Forbidden | अपर्याप्त permissions | token scopes या App permissions की जांच करें |
| 404 Not Found | access के बिना private repo | token या App को repository access दें |
| Rate limit exceeded | बहुत अधिक API calls | conditional requests enable करें और sync frequency कम करें |
| Webhooks प्राप्त नहीं हुए | गलत URL या firewall | सत्यापित करें कि webhook URL सार्वजनिक रूप से accessible है |
Debug Mode
connectors: github: debug: true log_level: verbose log_webhooks: trueConnection Test करें
tajo connectors test github# ✓ API authentication successful# ✓ Repository access verified# ✓ Issue data readable# ✓ Webhook delivery active# ✓ Rate limit healthy (4,850/5,000 remaining)सर्वोत्तम प्रथाएं
- PATs के बजाय GitHub Apps का उपयोग करें - GitHub Apps granular permissions और auto-refreshing tokens प्रदान करते हैं
- Webhook secrets enable करें - हमेशा HMAC-SHA256 के साथ webhook signatures सत्यापित करें
- Conditional requests का उपयोग करें - rate limit quota बर्बाद करने से बचने के लिए ETags का लाभ उठाएं
- बड़े responses को paginate करें - GitHub प्रति page अधिकतम 100 items लौटाता है;
Linkheaders के साथ iterate करें - कम गतिविधि के दौरान sync करें - peak development hours के बाहर full syncs schedule करें
- Rate limit headers monitor करें - सक्रिय रूप से throttle करने के लिए
X-RateLimit-Remainingकी जांच करें
सुरक्षा
- GitHub App Authentication - short-lived installation tokens के साथ RSA key-आधारित JWT
- Webhook Signatures - सभी webhook payloads पर HMAC-SHA256 signature verification
- Fine-Grained Tokens - विशिष्ट repositories और permissions तक scoped
- HTTPS Only - सभी API communication TLS 1.2+ के माध्यम से encrypted
- Encrypted Storage - Private keys और tokens Tajo में at rest encrypted
- Token Expiration - Fine-grained tokens auto-expire होते हैं; rotation alerts सेट करें