Update index.js #10
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: 🤖 Claude Review 🤖 | |
on: | |
issue_comment: | |
types: [created] | |
permissions: | |
checks: write | |
pull-requests: write | |
issues: write | |
jobs: | |
handle-review-command: | |
name: Process Review Request | |
if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, '/review') }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Start check run | |
id: create-check | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const { data: pr } = await github.rest.pulls.get({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
pull_number: context.issue.number | |
}); | |
const { data: check } = await github.rest.checks.create({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
name: 'Review Request', | |
head_sha: pr.head.sha, | |
status: 'in_progress', | |
started_at: new Date().toISOString(), | |
details_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`, | |
output: { | |
title: 'Processing Review Request', | |
summary: 'Processing /review command...' | |
} | |
}); | |
return check.id; | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.22' | |
cache: true | |
cache-dependency-path: scripts/go.sum | |
- name: Add label and comment | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
// Add the review label | |
await github.rest.issues.addLabels({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: context.issue.number, | |
labels: ['needs-review'] | |
}); | |
// Add the comment | |
await github.rest.issues.createComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: context.issue.number, | |
body: '👀 Review requested! I have added the needs-review label.' | |
}); | |
- name: Complete check run | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const { data: pr } = await github.rest.pulls.get({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
pull_number: context.issue.number | |
}); | |
await github.rest.checks.update({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
check_run_id: ${{ steps.create-check.outputs.result }}, | |
status: 'completed', | |
conclusion: 'success', | |
completed_at: new Date().toISOString(), | |
details_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`, | |
output: { | |
title: 'Review Requested', | |
summary: 'Review has been requested successfully via /review command' | |
} | |
}); |