anthropics / anthropics/claude-code-action

use_sticky_comment does not work with pull_request_target events

Aperta
#705 1 commento 6 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
TypeScript
Stelle
8.9k
Fork
2.1k
Merge medio
3g 9h
PR unite (30g)
10

Descrizione

## Describe the bug

`use_sticky_comment: true` only works with `pull_request` events and does not function with `pull_request_target` events. This forces users who need fork PR security to fall back to `gh pr comment`, which posts as `github-actions[bot]` instead of `claude[bot]`.

## To Reproduce

1. Create a workflow using `pull_request_target` trigger (required for secure fork PR handling)
2. Configure claude-code-action with `use_sticky_comment: true`
3. Open a PR from a fork
4. Observe that the sticky comment feature does not work

## Expected behavior

`use_sticky_comment` should work with both `pull_request` and `pull_request_target` events, allowing users to maintain fork PR security while still having comments posted as `claude[bot]`.

## Workflow yml file

```yaml
name: Claude Code Review
on:
pull_request_target:
types: [opened, synchronize, reopened]

jobs:
review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0

- uses: anthropics/claude-code-action@main
with:
use_sticky_comment: true # Does not work with pull_request_target
# ... other config
```

## API Provider

- [x] Anthropic First-Party API
- [ ] AWS Bedrock
- [ ] GCP Vertex

## Additional context

**Why this matters:**
- `pull_request_target` is the recommended approach for workflows that need secrets access when reviewing fork PRs
- Without this fix, users must choose between:
1. Fork PR security (`pull_request_target`) but comments from `github-actions[bot]`
2. Native `claude[bot]` comments (`pull_request` + `use_sticky_comment`) but no secure fork PR handling

**Workaround:** Use `gh pr comment` in the prompt, accepting that comments appear from `github-actions[bot]`.

**Related discussion:** [sjnims/requirements-expert#65](https://github.com/sjnims/requirements-expert/issues/65)

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.