name: Marvin Issue Dedupe # description: Automatically dedupe GitHub issues using Marvin on: issues: types: [opened] workflow_dispatch: inputs: issue_number: description: "Issue number to process for duplicate detection" required: true type: string jobs: marvin-dedupe-issues: runs-on: ubuntu-latest timeout-minutes: 10 permissions: contents: read issues: write id-token: write # TEMPORARY PIN — see the matching note in marvin-label-triage.yml. # Claude Code 2.1.216 broke every Bash call under the action's subprocess # isolation, which this workflow needs for all of its `gh` searching. # https://github.com/anthropics/claude-code/issues/79997 env: PINNED_CLAUDE_CODE_VERSION: "2.1.215" steps: - name: Checkout repository uses: actions/checkout@v7 - name: Generate Marvin App token id: marvin-token uses: actions/create-github-app-token@v3 with: app-id: ${{ secrets.MARVIN_APP_ID }} private-key: ${{ secrets.MARVIN_APP_PRIVATE_KEY }} - name: Set dedupe prompt id: dedupe-prompt run: | cat >> $GITHUB_OUTPUT << 'EOF' PROMPT<> "$GITHUB_OUTPUT" "$HOME/.local/bin/claude" --version - name: Run Marvin dedupe command uses: anthropics/claude-code-action@v1 with: path_to_claude_code_executable: ${{ steps.pin-claude.outputs.path }} github_token: ${{ steps.marvin-token.outputs.token }} bot_name: "Marvin Context Protocol" prompt: ${{ steps.dedupe-prompt.outputs.PROMPT }} anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY_FOR_CI }} allowed_non_write_users: "*" claude_args: | --allowedTools "Bash(gh issue view:*)","Bash(gh search:*)","Bash(gh issue list:*)","Bash(gh api:*)","Bash(gh issue comment:*)",Task settings: | { "model": "claude-sonnet-5", "env": { "GH_TOKEN": "${{ steps.marvin-token.outputs.token }}" } } - name: Add potential-duplicate label if bot commented in this run env: GH_TOKEN: ${{ steps.marvin-token.outputs.token }} run: | ISSUE=${{ github.event.issue.number || inputs.issue_number }} # Only match bot comments created in the last 10 minutes (this run) CUTOFF=$(date -u -d '10 minutes ago' '+%Y-%m-%dT%H:%M:%SZ' 2>/dev/null \ || date -u -v-10M '+%Y-%m-%dT%H:%M:%SZ') HAS_RECENT=$(gh api "repos/${{ github.repository }}/issues/${ISSUE}/comments?sort=created&direction=desc&per_page=10" \ --jq "[.[] | select( .user.type == \"Bot\" and (.body | test(\"possible duplicate issues\"; \"i\")) and .created_at >= \"${CUTOFF}\" )] | length") if [ "$HAS_RECENT" -gt 0 ]; then gh issue edit "$ISSUE" --add-label "potential-duplicate" -R "${{ github.repository }}" echo "Added potential-duplicate label to #${ISSUE}" else echo "No recent duplicate comment found, skipping label" fi