comment_on_potential_duplicate_issues.yml

 1name: Comment on potential duplicate bug/crash reports
 2
 3on:
 4  issues:
 5    types: [opened]
 6  workflow_dispatch:
 7    inputs:
 8      issue_number:
 9        description: "Issue number to analyze"
10        required: true
11        type: number
12
13concurrency:
14  group: potential-duplicate-check-${{ github.event.issue.number || inputs.issue_number }}
15  cancel-in-progress: true
16
17jobs:
18  identify-duplicates:
19    # For manual testing, allow running on any branch; for automatic runs, only on main repo
20    if: github.event_name == 'workflow_dispatch' || github.repository == 'zed-industries/zed'
21    runs-on: ubuntu-latest
22    timeout-minutes: 5
23
24    permissions:
25      contents: read
26      issues: write
27
28    steps:
29      - name: Checkout repository
30        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
31        with:
32          sparse-checkout: script/github-check-new-issue-for-duplicates.py
33          sparse-checkout-cone-mode: false
34
35      - name: Get github app token
36        id: get-app-token
37        uses: actions/create-github-app-token@bef1eaf1c0ac2b148ee2a0a74c65fbe6db0631f1 # v1.11.7
38        with:
39          app-id: ${{ secrets.ZED_COMMUNITY_BOT_APP_ID }}
40          private-key: ${{ secrets.ZED_COMMUNITY_BOT_PRIVATE_KEY }}
41          owner: zed-industries
42
43      - name: Set up Python
44        uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
45        with:
46          python-version: "3.12"
47
48      - name: Install dependencies
49        run: pip install requests
50
51      - name: Run duplicate detection
52        id: detect
53        env:
54          GITHUB_TOKEN: ${{ steps.get-app-token.outputs.token }}
55          ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY_ISSUE_DEDUP }}
56          ISSUE_NUMBER: ${{ github.event.issue.number || inputs.issue_number }}
57        run: |
58          python script/github-check-new-issue-for-duplicates.py "$ISSUE_NUMBER" > result.json
59          cat result.json
60
61      - name: Write job summary
62        if: always()
63        run: |
64          echo '```json' >> "$GITHUB_STEP_SUMMARY"
65          if [[ -f result.json ]] && jq empty result.json 2>/dev/null; then
66            jq . result.json >> "$GITHUB_STEP_SUMMARY"
67          else
68            echo '{"error": "No valid result.json generated. Check logs for details."}' >> "$GITHUB_STEP_SUMMARY"
69          fi
70          echo '```' >> "$GITHUB_STEP_SUMMARY"