forked from porter-dev/js-test-app
-
Notifications
You must be signed in to change notification settings - Fork 0
91 lines (85 loc) · 3.1 KB
/
comment_trigger.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
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'
}
});