Skip to content

Commit afd57be

Browse files
snomiaoclaude
andcommitted
feat: implement core ping system for important PR review tracking
- Add CorePing service to monitor Core/Core-Important labeled PRs - Implement timeline analysis to track review status and age - Clean up old gh-bugcop components and move to run directory - Add Docker configuration and deployment scripts - Update task routing and organization structure 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent d979969 commit afd57be

File tree

12 files changed

+409
-31
lines changed

12 files changed

+409
-31
lines changed

run/core-review.tsx renamed to app/tasks/coreping/index.tsx

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,32 @@ import DIE from "@snomiao/die";
1010
import chalk from "chalk";
1111
import sflow, { pageFlow } from "sflow";
1212
import { P } from "ts-pattern";
13-
14-
// rules:
15-
// Scann all github prs with labels Core-*
16-
// when Core-Important
17-
// when after pr-review/pr-comment, add comment can set "Core-Ready-For-Review", by '+Core-Ready-For-Review'
18-
//
13+
/**
14+
* [Comfy- CorePing] The Core/Important PR Review Reminder Service
15+
* This service reminders @comfyanonymous for unreviewed Core/Core-Important PRs every 24 hours in the morning 8am of california
16+
*
17+
* Environment: it's designed to be run in github actions by cron-job.
18+
*
19+
* Usage: run this script in github actions by cron job, it will scan all Core/Important PRs and send a slack message to @comfyanonymous
20+
*
21+
* How should it works:
22+
*
23+
* Scan all comfy-prs, with labels 'Core-*'
24+
* match theLabel("Core-Important") or theLabel("Core")
25+
* check if the pr is reviewed (after the label added):
26+
* when it's not reviewed yet:
27+
* < 24h since the labeled event to now: fresh
28+
* > 24h since the labeled event to now: stale
29+
* Collect and send @comfy reminder
30+
* when it's reviewed by @comfy after label:
31+
* after pr-review/pr-comment, add comment can set "Core-Ready-For-Review", by '+label:Core-Ready-For-Review'
32+
* match theLabel('Core-Ready-For-Review'):
33+
*
34+
*/
1935
export const coreReviewTrackerConfig = {
2036
REPOLIST: [
21-
"https://github.com/Comfy-Org/Comfy-PR",
2237
"https://github.com/comfyanonymous/ComfyUI",
38+
"https://github.com/Comfy-Org/Comfy-PR",
2339
"https://github.com/Comfy-Org/ComfyUI_frontend",
2440
"https://github.com/Comfy-Org/desktop",
2541
],
@@ -190,7 +206,7 @@ if (import.meta.main) {
190206
.join("\n");
191207
const freshCorePRs = corePRs.filter((pr) => pr.status === "fresh");
192208

193-
const notifyMessage = `Hey <@comfy>, Here's x${staleCorePRs.length} Core/Important PRs waiting your feedback!\n${staleCorePRsMessage}\n... and there are ${freshCorePRs.length} more fresh Core/Core-Important PRs. cc <@Yoland>`;
209+
const notifyMessage = `Hey <@comfy>, Here's x${staleCorePRs.length} Core/Important PRs waiting your feedback!\n\n${staleCorePRsMessage}\n... and there are ${freshCorePRs.length} more fresh Core/Core-Important PRs.\n cc <@Yoland> <@snomiao>`;
194210
console.log(chalk.bgBlue(notifyMessage));
195211

196212
// TODO: update message with delete line when it's reviewed

app/tasks/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { GithubActionUpdateTask } from "@/src/GithubActionUpdateTask/GithubActionUpdateTask";
22
import Link from "next/link";
33
import { Suspense } from "react";
4+
import { GithubBugcopTask } from "../../run/gh-bugcop/gh-bugcop";
45
import { GithubBountyTask } from "./gh-bounty/gh-bounty";
5-
import { GithubBugcopTask } from "./gh-bugcop/gh-bugcop";
66
import { GithubDesignTask } from "./gh-design/gh-design";
77
import {
88
GithubContributorAnalyzeTask,

app/tasks/run-gh-tasks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { db } from "@/src/db";
33
import isCI from "is-ci";
44

55
// Import all the 5-minute tasks
6+
import runGithubBugcopTask from "../../run/gh-bugcop/gh-bugcop";
67
import runGithubBountyTask from "./gh-bounty/gh-bounty";
7-
import runGithubBugcopTask from "./gh-bugcop/gh-bugcop";
88
import { runGithubDesignTask } from "./gh-design/gh-design";
99
import runGithubDesktopReleaseNotificationTask from "./gh-desktop-release-notification/index";
1010

run/.dockerignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
node_modules
2+
.git
3+
.gitignore
4+
README.md
5+
Dockerfile
6+
.dockerignore
7+
cloudbuild.yaml
8+
deploy.sh
9+
*.log
10+
.env*
11+
.vscode
12+
.idea

run/Dockerfile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Use official Bun image
2+
FROM oven/bun:1.1.21-slim
3+
4+
# Set working directory
5+
WORKDIR /app
6+
7+
# Copy package files
8+
COPY package.json bun.lock ./
9+
10+
# Install dependencies
11+
RUN bun install --production --ignore-scripts
12+
13+
# Copy source code
14+
COPY src ./src
15+
COPY run ./run
16+
17+
# Create necessary directories and set permissions
18+
RUN mkdir -p /app/node_modules/.cache/Comfy-PR && \
19+
chmod 755 /app/node_modules/.cache/Comfy-PR
20+
21+
# Expose port
22+
EXPOSE 8080
23+
24+
# Set environment variables
25+
ENV NODE_ENV=production
26+
ENV PORT=8080
27+
28+
# Health check
29+
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
30+
CMD curl -f http://localhost:8080/health || exit 1
31+
32+
# Run the webhook service
33+
CMD ["bun", "run/index.tsx"]

run/README.md

Lines changed: 103 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,117 @@
1-
# gh-service: GitHub Repository Event Monitor
1+
# GitHub Webhook Service Deployment
22

3-
Real-time monitoring system for GitHub repository events across multiple repositories.
3+
This directory contains the GitHub webhook service and deployment configuration for Google Cloud Run.
44

5-
## Features
5+
## Overview
66

7-
- **Real-time notifications** for issues, PRs, comments, and label changes
8-
- **Dual mode support**: Webhooks (real-time) or Polling (30s interval)
9-
- **Multi-repository monitoring** across 4 Comfy-Org repositories
10-
- **Secure webhook verification** with HMAC signatures
11-
- **Automatic webhook setup** with graceful fallback to polling
7+
The webhook service (`index.tsx`) monitors GitHub repositories for events like issues, pull requests, and comments. It can operate in two modes:
128

13-
## Quick Start
9+
- **Webhook mode**: Real-time event handling via GitHub webhooks
10+
- **Polling mode**: Fallback polling when webhooks can't be configured
1411

15-
### Polling Mode (Default)
12+
## Prerequisites
13+
14+
1. **Google Cloud CLI**: Install and authenticate with `gcloud auth login`
15+
2. **Docker**: Required for building container images
16+
3. **Project Setup**: Enable billing on your Google Cloud project
17+
4. **GitHub Token**: Personal Access Token with repo permissions
18+
5. **Webhook Secret**: Secret for securing webhook payloads
19+
20+
## Environment Variables
21+
22+
The service requires these environment variables:
23+
24+
### Required
25+
26+
- `GITHUB_TOKEN`: GitHub Personal Access Token
27+
- `GITHUB_WEBHOOK_SECRET`: Secret for webhook signature validation
28+
- `PORT`: Server port (defaults to 8080)
29+
30+
### Optional
31+
32+
- `GITHUB_WEBHOOK_BASEURL`: Base URL for webhook endpoints
33+
- `GITHUB_WEBHOOK_PORT`: Alternative port setting
34+
35+
## Deployment
36+
37+
### Quick Deploy
1638

1739
```bash
18-
bun run run/gh-service.tsx
40+
# Set environment variables
41+
export GOOGLE_CLOUD_PROJECT="your-project-id"
42+
export GITHUB_TOKEN="ghp_your_token_here"
43+
export GITHUB_WEBHOOK_SECRET="your_webhook_secret"
44+
45+
# Deploy
46+
cd run
47+
./deploy.sh
1948
```
2049

21-
### Webhook Mode (Real-time)
50+
### Manual Deploy Steps
51+
52+
1. **Enable APIs**:
53+
54+
```bash
55+
gcloud services enable cloudbuild.googleapis.com run.googleapis.com artifactregistry.googleapis.com secretmanager.googleapis.com
56+
```
57+
58+
2. **Create Artifact Registry**:
59+
60+
```bash
61+
gcloud artifacts repositories create github-webhook-service \
62+
--repository-format=docker \
63+
--location=us-central1
64+
```
65+
66+
3. **Create Secrets**:
67+
68+
```bash
69+
echo "$GITHUB_TOKEN" | gcloud secrets create github-token --data-file=-
70+
echo "$GITHUB_WEBHOOK_SECRET" | gcloud secrets create github-webhook-secret --data-file=-
71+
```
72+
73+
4. **Build and Deploy**:
74+
```bash
75+
gcloud builds submit . --config=cloudbuild.yaml
76+
```
77+
78+
## Files
79+
80+
- `index.tsx` - Main webhook service application
81+
- `Dockerfile` - Container build configuration
82+
- `cloudbuild.yaml` - Cloud Build deployment configuration
83+
- `deploy.sh` - Automated deployment script
84+
- `README.md` - This documentation
85+
86+
## Service Endpoints
87+
88+
- `/` - Root endpoint with basic info
89+
- `/api/github/webhook` - GitHub webhook endpoint
90+
- `/health` - Health check endpoint
91+
92+
## GitHub Webhook Configuration
93+
94+
After deployment, configure your GitHub repositories:
95+
96+
1. Go to Repository Settings → Webhooks
97+
2. Add webhook with URL: `https://your-service-url/api/github/webhook`
98+
3. Set content type to `application/json`
99+
4. Enter your webhook secret
100+
5. Select events: Issues, Pull requests, Issue comments, Pull request reviews, Labels
101+
102+
## Local Development
22103

23104
```bash
24-
export USE_WEBHOOKS=true
25-
export GITHUB_WEBHOOK_SECRET=your-webhook-secret
26-
export WEBHOOK_BASE_URL=https://your-public-domain.com
27-
bun run run/gh-service.tsx
105+
# Install dependencies
106+
bun install
107+
108+
# Set environment variables
109+
export GITHUB_TOKEN="your_token"
110+
export GITHUB_WEBHOOK_SECRET="your_secret"
111+
export PORT=3000
112+
113+
# Run locally
114+
bun run index.tsx
28115
```
29116

30117
## Getting Your Webhook Secret

run/cloudbuild.yaml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
steps:
2+
# Build the container image
3+
- name: "gcr.io/cloud-builders/docker"
4+
args:
5+
- "build"
6+
- "-t"
7+
- "${_LOCATION}-docker.pkg.dev/${PROJECT_ID}/${_REPOSITORY}/github-webhook-service:latest"
8+
- "-f"
9+
- "run/Dockerfile"
10+
- "."
11+
id: "build-image"
12+
13+
# Push the container image to Artifact Registry
14+
- name: "gcr.io/cloud-builders/docker"
15+
args:
16+
- "push"
17+
- "${_LOCATION}-docker.pkg.dev/${PROJECT_ID}/${_REPOSITORY}/github-webhook-service:latest"
18+
id: "push-image"
19+
20+
# Deploy container image to Cloud Run
21+
- name: "gcr.io/google.com/cloudsdktool/cloud-sdk"
22+
entrypoint: gcloud
23+
args:
24+
- "run"
25+
- "deploy"
26+
- "${_SERVICE_NAME}"
27+
- "--image"
28+
- "${_LOCATION}-docker.pkg.dev/${PROJECT_ID}/${_REPOSITORY}/github-webhook-service:latest"
29+
- "--region"
30+
- "${_LOCATION}"
31+
- "--platform"
32+
- "managed"
33+
- "--allow-unauthenticated"
34+
- "--port"
35+
- "8080"
36+
- "--memory"
37+
- "1Gi"
38+
- "--cpu"
39+
- "1"
40+
- "--min-instances"
41+
- "0"
42+
- "--max-instances"
43+
- "10"
44+
- "--set-env-vars"
45+
- "NODE_ENV=production"
46+
- "--update-secrets"
47+
- "GITHUB_TOKEN=github-token:latest"
48+
- "--update-secrets"
49+
- "GITHUB_WEBHOOK_SECRET=github-webhook-secret:latest"
50+
- "--set-env-vars"
51+
- "GITHUB_WEBHOOK_BASEURL=${_WEBHOOK_BASE_URL}"
52+
id: "deploy-service"
53+
54+
images:
55+
- "${_LOCATION}-docker.pkg.dev/${PROJECT_ID}/${_REPOSITORY}/github-webhook-service:latest"
56+
57+
# Substitution variables
58+
substitutions:
59+
_LOCATION: "us-central1"
60+
_REPOSITORY: "github-webhook-service"
61+
_SERVICE_NAME: "github-webhook-service"
62+
_WEBHOOK_BASE_URL: "https://github-webhook-service-REPLACE_WITH_HASH-uc.a.run.app"
63+
64+
options:
65+
logging: CLOUD_LOGGING_ONLY
66+
machineType: "E2_HIGHCPU_8"
67+
68+
timeout: "1200s"

0 commit comments

Comments
 (0)