forked from CopilotKit/CopilotKit
-
Notifications
You must be signed in to change notification settings - Fork 0
108 lines (98 loc) · 3.9 KB
/
Copy pathshowcase_eval_check.yml
File metadata and controls
108 lines (98 loc) · 3.9 KB
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
name: "Showcase: Eval Check"
on:
pull_request:
types: [opened, synchronize, reopened]
permissions:
contents: read
jobs:
create-check:
if: false
runs-on: ubuntu-latest
timeout-minutes: 2
permissions:
contents: read
pull-requests: write
issues: write
steps:
- name: Generate devops-bot token
id: bot-token
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
with:
app-id: 1108748
private-key: ${{ secrets.DEVOPS_BOT_PRIVATE_KEY }}
permission-checks: write
permission-issues: write
permission-pull-requests: write
- name: Create Check Run
id: check-run
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7
with:
github-token: ${{ steps.bot-token.outputs.token }}
script: |
const result = await github.rest.checks.create({
owner: context.repo.owner,
repo: context.repo.repo,
name: "Showcase Eval",
head_sha: context.payload.pull_request.head.sha,
status: "completed",
conclusion: "neutral",
external_id: String(context.payload.pull_request.number),
output: {
title: "Showcase Eval — click to run",
summary: "Evaluates this PR against the showcase integration matrix.\n\n_For targeted runs, comment `/eval d5 slug1,slug2` on the PR._",
},
actions: [
{
label: "Run Showcase Eval",
description: "Run D5 evaluation",
identifier: "run-eval",
},
],
});
core.setOutput('check_run_id', result.data.id);
- name: Post or update bot comment with trigger link
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7
with:
github-token: ${{ steps.bot-token.outputs.token }}
script: |
const crypto = require('crypto');
const pr = String(context.payload.pull_request.number);
const checkRunId = String(${{ steps.check-run.outputs.check_run_id }});
const secret = process.env.WEBHOOK_SECRET;
const sig = crypto
.createHmac('sha256', secret)
.update(`${pr}:${checkRunId}`)
.digest('hex');
const baseUrl = 'https://hooks.showcase.copilotkit.ai';
const triggerUrl = `${baseUrl}/trigger/eval?pr=${pr}&check_run_id=${checkRunId}&sig=${sig}`;
const marker = '<!-- showcase-eval-button -->';
const body = `${marker}\n\n` +
`### 🔬 Showcase Eval\n\n` +
`Evaluate this PR against the showcase integration matrix.\n\n` +
`[**▶ Run Evaluation**](${triggerUrl})\n\n` +
`_For targeted runs: \`/eval d5 slug1,slug2\`_`;
// Find existing bot comment
const comments = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
per_page: 100,
});
const existing = comments.data.find(c => c.body?.includes(marker));
if (existing) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existing.id,
body,
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
body,
});
}
env:
WEBHOOK_SECRET: ${{ secrets.EVAL_WEBHOOK_SECRET }}