diff --git a/.github/workflows/marvin-comment-on-issue.yml b/.github/workflows/marvin-comment-on-issue.yml index 7c6a5ccf9..9a8a26522 100644 --- a/.github/workflows/marvin-comment-on-issue.yml +++ b/.github/workflows/marvin-comment-on-issue.yml @@ -16,6 +16,7 @@ permissions: jobs: comment: if: | + !github.event.issue.pull_request && contains(github.event.comment.body, '/marvin') && contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.comment.author_association) runs-on: ubuntu-latest diff --git a/.github/workflows/marvin-comment-on-pr.yml b/.github/workflows/marvin-comment-on-pr.yml index 561d96ca2..ffa4892b4 100644 --- a/.github/workflows/marvin-comment-on-pr.yml +++ b/.github/workflows/marvin-comment-on-pr.yml @@ -1,13 +1,11 @@ -# Respond to /marvin mentions in PR comments or PR body (elastic mention-in-pr style) +# Respond to /marvin mentions in PR review comments and issue comments on PRs # Calls run-claude directly name: Comment on PR on: - pull_request_review_comment: + issue_comment: types: [created] - pull_request: - types: [opened, edited] permissions: contents: write @@ -18,12 +16,9 @@ permissions: jobs: comment: if: | - (github.event_name == 'pull_request_review_comment' && - contains(github.event.comment.body, '/marvin') && - contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.comment.author_association)) || - (github.event_name == 'pull_request' && - contains(github.event.pull_request.body, '/marvin') && - contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.pull_request.author_association)) + github.event.issue.pull_request && + contains(github.event.comment.body, '/marvin') && + contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.comment.author_association) runs-on: ubuntu-latest timeout-minutes: 15 @@ -31,6 +26,7 @@ jobs: - name: Checkout PR head branch uses: actions/checkout@v6 with: + # do not set to pull_request.head.ref, claude will pull the branch if needed fetch-depth: 0 - name: Install UV @@ -55,35 +51,29 @@ jobs: private-key: ${{ secrets.MARVIN_APP_PRIVATE_KEY }} - name: React to comment with eyes - if: github.event_name == 'pull_request_review_comment' env: GH_TOKEN: ${{ steps.marvin-token.outputs.token }} run: | gh api "repos/${{ github.repository }}/issues/comments/${{ github.event.comment.id }}/reactions" -f content=eyes 2>/dev/null || true - - name: React to PR with eyes - if: github.event_name == 'pull_request' - env: - GH_TOKEN: ${{ steps.marvin-token.outputs.token }} - run: | - gh api "repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/reactions" -f content=eyes 2>/dev/null || true - - name: Get PR HEAD SHA id: pr-info env: GH_TOKEN: ${{ steps.marvin-token.outputs.token }} run: | - HEAD_SHA=$(gh api "repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}" --jq '.head.sha') + PR_NUMBER="${{ github.event.issue.number }}" + HEAD_SHA=$(gh api "repos/${{ github.repository }}/pulls/${PR_NUMBER}" --jq '.head.sha') echo "head_sha=${HEAD_SHA}" >> "$GITHUB_OUTPUT" + echo "pr_number=${PR_NUMBER}" >> "$GITHUB_OUTPUT" - name: Run Claude for PR Comment uses: ./.github/actions/run-claude env: MENTION_REPO: ${{ github.repository }} - MENTION_PR_NUMBER: ${{ github.event.pull_request.number }} + MENTION_PR_NUMBER: ${{ steps.pr-info.outputs.pr_number }} MENTION_SCRIPTS: ${{ github.workspace }}/.github/scripts/mention PR_REVIEW_REPO: ${{ github.repository }} - PR_REVIEW_PR_NUMBER: ${{ github.event.pull_request.number }} + PR_REVIEW_PR_NUMBER: ${{ steps.pr-info.outputs.pr_number }} PR_REVIEW_HEAD_SHA: ${{ steps.pr-info.outputs.head_sha }} PR_REVIEW_COMMENTS_DIR: /tmp/pr-review-comments PR_REVIEW_HELPERS_DIR: ${{ github.workspace }}/.github/scripts/pr-review @@ -96,16 +86,16 @@ jobs: prompt: | Repository: ${{ github.repository }} - PR Number: #${{ github.event.pull_request.number }} - PR Title: ${{ github.event.pull_request.title }} - PR Author: ${{ github.event.pull_request.user.login }} - Comment Author: ${{ github.event.comment.user.login || github.event.pull_request.user.login }} + PR Number: #${{ steps.pr-info.outputs.pr_number }} + PR Title: ${{ github.event.issue.title }} + PR Author: ${{ github.event.issue.user.login }} + Comment Author: ${{ github.event.comment.user.login }} **Note**: The PR head branch has already been checked out. The workspace is ready - you can immediately start working on the PR code. - ${{ github.event.comment.body || github.event.pull_request.body }} + ${{ github.event.comment.body }}