anthropics / anthropics/claude-code-action

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

Open
#794 0 comments 1 reaction 0 assignees View on GitHub
area:installation bug dev-experience p2
Dominant language
TypeScript
Stars
8.9k
Forks
2.1k
Avg merge
3d 9h
Merged PRs (30d)
10

Description

## 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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.