Skip to content

Commit 09a0200

Browse files
committed
Restore dedupe workflows
This reverts commit d81efef.
1 parent f5f6c76 commit 09a0200

5 files changed

Lines changed: 645 additions & 0 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Auto-close duplicate issues
2+
description: Auto-closes issues that are duplicates of existing issues
3+
on:
4+
schedule:
5+
- cron: "0 9 * * *"
6+
workflow_dispatch:
7+
8+
jobs:
9+
auto-close-duplicates:
10+
runs-on: ubuntu-latest
11+
timeout-minutes: 10
12+
permissions:
13+
contents: read
14+
issues: write
15+
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
20+
- name: Setup Bun
21+
uses: oven-sh/setup-bun@v2
22+
with:
23+
bun-version: latest
24+
25+
- name: Auto-close duplicate issues
26+
run: bun run scripts/auto-close-duplicates.ts
27+
env:
28+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29+
GITHUB_REPOSITORY_OWNER: ${{ github.repository_owner }}
30+
GITHUB_REPOSITORY_NAME: ${{ github.event.repository.name }}
31+
STATSIG_API_KEY: ${{ secrets.STATSIG_API_KEY }}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Backfill Duplicate Comments
2+
description: Triggers duplicate detection for old issues that don't have duplicate comments
3+
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
days_back:
8+
description: 'How many days back to look for old issues'
9+
required: false
10+
default: '90'
11+
type: string
12+
dry_run:
13+
description: 'Dry run mode (true to only log what would be done)'
14+
required: false
15+
default: 'true'
16+
type: choice
17+
options:
18+
- 'true'
19+
- 'false'
20+
21+
jobs:
22+
backfill-duplicate-comments:
23+
runs-on: ubuntu-latest
24+
timeout-minutes: 30
25+
permissions:
26+
contents: read
27+
issues: read
28+
actions: write
29+
30+
steps:
31+
- name: Checkout repository
32+
uses: actions/checkout@v4
33+
34+
- name: Setup Bun
35+
uses: oven-sh/setup-bun@v2
36+
with:
37+
bun-version: latest
38+
39+
- name: Backfill duplicate comments
40+
run: bun run scripts/backfill-duplicate-comments.ts
41+
env:
42+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43+
DAYS_BACK: ${{ inputs.days_back }}
44+
DRY_RUN: ${{ inputs.dry_run }}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Claude Issue Dedupe
2+
description: Automatically dedupe GitHub issues using Claude Code
3+
on:
4+
issues:
5+
types: [opened]
6+
workflow_dispatch:
7+
inputs:
8+
issue_number:
9+
description: 'Issue number to process for duplicate detection'
10+
required: true
11+
type: string
12+
13+
jobs:
14+
claude-dedupe-issues:
15+
runs-on: ubuntu-latest
16+
timeout-minutes: 10
17+
permissions:
18+
contents: read
19+
issues: write
20+
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
25+
- name: Run Claude Code slash command
26+
uses: anthropics/claude-code-base-action@beta
27+
with:
28+
prompt: "/dedupe ${{ github.repository }}/issues/${{ github.event.issue.number || inputs.issue_number }}"
29+
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
30+
claude_env: |
31+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32+
33+
- name: Log duplicate comment event to Statsig
34+
if: always()
35+
env:
36+
STATSIG_API_KEY: ${{ secrets.STATSIG_API_KEY }}
37+
run: |
38+
ISSUE_NUMBER=${{ github.event.issue.number || inputs.issue_number }}
39+
REPO=${{ github.repository }}
40+
41+
if [ -z "$STATSIG_API_KEY" ]; then
42+
echo "STATSIG_API_KEY not found, skipping Statsig logging"
43+
exit 0
44+
fi
45+
46+
# Prepare the event payload
47+
EVENT_PAYLOAD=$(jq -n \
48+
--arg issue_number "$ISSUE_NUMBER" \
49+
--arg repo "$REPO" \
50+
--arg triggered_by "${{ github.event_name }}" \
51+
'{
52+
events: [{
53+
eventName: "github_duplicate_comment_added",
54+
value: 1,
55+
metadata: {
56+
repository: $repo,
57+
issue_number: ($issue_number | tonumber),
58+
triggered_by: $triggered_by,
59+
workflow_run_id: "${{ github.run_id }}"
60+
},
61+
time: (now | floor | tostring)
62+
}]
63+
}')
64+
65+
# Send to Statsig API
66+
echo "Logging duplicate comment event to Statsig for issue #${ISSUE_NUMBER}"
67+
68+
RESPONSE=$(curl -s -w "\n%{http_code}" -X POST https://events.statsigapi.net/v1/log_event \
69+
-H "Content-Type: application/json" \
70+
-H "STATSIG-API-KEY: ${STATSIG_API_KEY}" \
71+
-d "$EVENT_PAYLOAD")
72+
73+
HTTP_CODE=$(echo "$RESPONSE" | tail -n1)
74+
BODY=$(echo "$RESPONSE" | head -n-1)
75+
76+
if [ "$HTTP_CODE" -eq 200 ] || [ "$HTTP_CODE" -eq 202 ]; then
77+
echo "Successfully logged duplicate comment event for issue #${ISSUE_NUMBER}"
78+
else
79+
echo "Failed to log duplicate comment event for issue #${ISSUE_NUMBER}. HTTP ${HTTP_CODE}: ${BODY}"
80+
fi

0 commit comments

Comments
 (0)