anthropics / anthropics/claude-code-action

Bot comment still triggers workflow run even with user.type != 'Bot' condition

Abierto
#794 0 comentarios 1 reacción 0 asignados Ver en GitHub
area:installation bug dev-experience p2
Lenguaje dominante
TypeScript
Estrellas
8.9k
Forks
2.1k
Merge medio
3 d 9 h
PR fusionados (30 d)
10

Descripción

## Summary

When using `github.event.comment.user.type != 'Bot'` in the job's `if` condition, the bot's comment still triggers a workflow run (though the job gets skipped). This causes two workflow runs for every `@claude` mention.

## Current Behavior

1. User comments `@claude review` on a PR
2. Workflow run #1 starts (triggered by user comment)
3. Claude bot responds with a comment
4. Workflow run #2 starts (triggered by bot comment), but job is **skipped** due to `user.type != 'Bot'` condition

The problem is that the workflow run is still created, which:
- Clutters the Actions tab with duplicate runs
- Can interfere with concurrency controls (as noted in #625)

## Workflow Configuration

```yaml
on:
issue_comment:
types: [created]
pull_request_review_comment:
types: [created]

concurrency:
group: ${{ github.workflow }}-${{ github.event.comment.id || github.event.issue.number || github.run_id }}
cancel-in-progress: false

jobs:
respond-to-mention:
if: |
(github.event_name == 'issue_comment' ||
github.event_name == 'pull_request_review_comment') &&
contains(github.event.comment.body, '@claude') &&
github.event.comment.user.type != 'Bot'
runs-on: ubuntu-latest
# ...
```

## Example Runs

| Run | Triggered By | Status | Duration |
|-----|--------------|--------|----------|
| #15 | claude[bot] | skipped | 1s |
| #14 | tangyu | success | 2m 36s |

Both runs were triggered by the same `@claude` mention - #14 by the user, #15 by the bot's response.

## Expected Behavior

Only one workflow run should be created per `@claude` mention.

## Suggested Fix

As suggested in #625, using `github.actor != 'claude[bot]'` at the workflow level might help:

```yaml
jobs:
respond-to-mention:
if: |
github.actor != 'claude[bot]' &&
(github.event_name == 'issue_comment' ||
github.event_name == 'pull_request_review_comment') &&
contains(github.event.comment.body, '@claude')
```

However, this still creates a workflow run that gets skipped.

**Ideally**, GitHub Actions would support filtering at the trigger level based on the comment author, but this is a GitHub limitation.

## Workaround

We're currently using:
- `github.event.comment.user.type != 'Bot'` to skip the job
- `cancel-in-progress: false` to prevent the skipped run from canceling the real one
- `github.event.comment.id` in concurrency group to isolate runs

This works, but results in duplicate (skipped) workflow runs in the Actions tab.

## Related Issues

- #625 - Generated workflows missing id-token:write permission and trigger on bot's own comments

## Environment

- claude-code-action: v1
- Trigger: issue_comment, pull_request_review_comment

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.