-
Notifications
You must be signed in to change notification settings - Fork 19
51 lines (46 loc) · 1.6 KB
/
benchmark.yml
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
on:
pull_request:
permissions:
pull-requests: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
benchmark:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- ref: ${{ github.base_ref }}
name: base
- ref: ${{ github.head_ref }}
name: head
steps:
- uses: actions/checkout@v3
with:
ref: ${{ matrix.ref }}
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.2"
bundler-cache: true
- uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { issue: { number: issue_number }, repo: { owner, repo } } = context;
const { data: comments } = await github.rest.issues.listComments({ owner, repo, issue_number });
const existingComment = comments.find(comment => comment.user.login === "github-actions[bot]" && comment.body.includes("Benchmark result: ${{ matrix.name }}"))
const { execSync } = require("child_process");
const result = execSync("bin/benchmark");
const body = `
Benchmark result: ${{ matrix.name }} (${{ matrix.ref }})
\`\`\`
${result}
\`\`\`
`;
if (existingComment) {
github.rest.issues.updateComment({ owner, repo, body, comment_id: existingComment.id });
} else {
github.rest.issues.createComment({ owner, repo, body, issue_number });
}