bitbucket-gemini-action 1.0.11 → 1.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +115 -0
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -52,6 +52,8 @@ pipelines:
52
52
  - `@gemini what does this function do?`
53
53
  - `@gemini check for security issues`
54
54
 
55
+ > **Note**: `@gemini` 멘션 기능을 사용하려면 [웹훅 설정](#webhook-setup-for-gemini-mentions)이 필요합니다.
56
+
55
57
  ## Configuration
56
58
 
57
59
  ### Environment Variables
@@ -235,6 +237,119 @@ Triggered by providing a `PROMPT` variable. Executes predefined tasks automatica
235
237
  - npx bitbucket-gemini-action
236
238
  ```
237
239
 
240
+ ### 자동 리뷰 + @gemini 멘션 동시 사용
241
+
242
+ 두 기능을 동시에 사용하려면:
243
+
244
+ 1. **자동 리뷰**: `PROMPT` 환경변수로 PR 생성/업데이트 시 자동 실행
245
+ 2. **@gemini 멘션**: 웹훅으로 코멘트 이벤트 수신 시 실행
246
+
247
+ ```yaml
248
+ image: node:20
249
+
250
+ pipelines:
251
+ pull-requests:
252
+ '**':
253
+ - step:
254
+ name: AI Code Review
255
+ script:
256
+ - export PROMPT="Review this PR"
257
+ - export ALLOW_BOTS=true
258
+ - export REVIEW_PRESETS="middle,nextjs,typescript"
259
+ - npx bitbucket-gemini-action@latest
260
+
261
+ custom:
262
+ gemini-comment:
263
+ - step:
264
+ name: Gemini Comment Handler
265
+ script:
266
+ - export ALLOW_BOTS=true
267
+ - npx bitbucket-gemini-action@latest
268
+ ```
269
+
270
+ - `pull-requests` 파이프라인: PR 생성/업데이트 시 자동 리뷰
271
+ - `custom/gemini-comment` 파이프라인: 웹훅에서 코멘트 이벤트 수신 시 `@gemini` 멘션 처리
272
+
273
+ ## Webhook Setup for @gemini Mentions
274
+
275
+ `@gemini` 멘션 기능을 사용하려면 Bitbucket 웹훅과 중간 서버가 필요합니다.
276
+
277
+ ### 왜 중간 서버가 필요한가?
278
+
279
+ Bitbucket Pipelines는 **외부 웹훅 URL로 직접 트리거할 수 없습니다**. 따라서:
280
+
281
+ 1. 웹훅 → 중간 서버 → Bitbucket API로 파이프라인 트리거
282
+
283
+ ### 옵션 1: 외부 서버 사용 (권장)
284
+
285
+ AWS Lambda, Cloudflare Workers, 또는 별도 서버에서 웹훅을 수신하고 Bitbucket API를 호출:
286
+
287
+ ```javascript
288
+ // Cloudflare Worker 예시
289
+ export default {
290
+ async fetch(request, env) {
291
+ const payload = await request.json();
292
+
293
+ // @gemini 멘션 확인
294
+ if (!payload.comment?.content?.raw?.includes('@gemini')) {
295
+ return new Response('No trigger', { status: 200 });
296
+ }
297
+
298
+ // Bitbucket Pipeline API 호출
299
+ const response = await fetch(
300
+ `https://api.bitbucket.org/2.0/repositories/${payload.repository.full_name}/pipelines/`,
301
+ {
302
+ method: 'POST',
303
+ headers: {
304
+ 'Authorization': `Bearer ${env.BITBUCKET_ACCESS_TOKEN}`,
305
+ 'Content-Type': 'application/json',
306
+ },
307
+ body: JSON.stringify({
308
+ target: {
309
+ ref_type: 'branch',
310
+ type: 'pipeline_ref_target',
311
+ ref_name: payload.pullrequest.source.branch.name,
312
+ selector: {
313
+ type: 'custom',
314
+ pattern: 'gemini-comment',
315
+ },
316
+ },
317
+ variables: [
318
+ { key: 'WEBHOOK_PAYLOAD', value: JSON.stringify(payload) },
319
+ { key: 'TRIGGER_EVENT', value: 'pullrequest:comment_created' },
320
+ ],
321
+ }),
322
+ }
323
+ );
324
+
325
+ return new Response('Pipeline triggered', { status: 200 });
326
+ },
327
+ };
328
+ ```
329
+
330
+ ### 옵션 2: Bitbucket Connect 앱 개발
331
+
332
+ 더 깊은 통합이 필요하면 Bitbucket Connect 앱을 개발하세요.
333
+
334
+ ### 웹훅 설정 방법
335
+
336
+ 1. **Repository Settings → Webhooks → Add webhook**
337
+ 2. **Title**: `bitbucket-gemini`
338
+ 3. **URL**: 중간 서버 URL (예: `https://your-worker.workers.dev/webhook`)
339
+ 4. **Triggers 선택**:
340
+ - ✅ Pull request: Comment created
341
+ - ✅ Pull request: Comment updated (선택사항)
342
+ 5. **Save**
343
+
344
+ ### 환경 변수
345
+
346
+ 웹훅 핸들러에서 파이프라인 트리거 시 다음 변수를 전달해야 합니다:
347
+
348
+ | Variable | Description |
349
+ |----------|-------------|
350
+ | `WEBHOOK_PAYLOAD` | 웹훅 페이로드 JSON 문자열 |
351
+ | `TRIGGER_EVENT` | `pullrequest:comment_created` 또는 `pullrequest:comment_updated` |
352
+
238
353
  ## Pipeline Examples
239
354
 
240
355
  ### Basic PR Review
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bitbucket-gemini-action",
3
- "version": "1.0.11",
3
+ "version": "1.0.12",
4
4
  "description": "Bitbucket Pipeline action for AI-powered code review using Google Gemini",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",