forked from cvxpy/cvxpy
-
Notifications
You must be signed in to change notification settings - Fork 0
75 lines (67 loc) · 2.5 KB
/
pr_benchmark_comment.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
name: pr_benchmark_comment
on:
workflow_run:
workflows: [pr_benchmarks]
types:
- completed
jobs:
comment_pr:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Download artifact
uses: actions/github-script@v6
with:
# Script taken from official github documentation.
# Link: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#using-data-from-the-triggering-workflow
script: |
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
});
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
return artifact.name == "comment_log"
})[0];
let download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
let fs = require('fs');
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/comment_log.zip`, Buffer.from(download.data));
- name: Unzip artifact
run: unzip comment_log.zip
- id: get-comment-body
run: |
body="$(cat asv_compare.log)"
body="${body//'%'/'%25'}"
body="${body//$'\n'/'%0A'}"
body="${body//$'\r'/'%0D'}"
echo "::set-output name=body::$body"
- id: get-pr-number
run: |
number="$(cat pr_number)"
echo "::set-output name=number::$number"
- name: Find Comment
uses: peter-evans/find-comment@v2
id: fc
with:
issue-number: ${{ steps.get-pr-number.outputs.number }}
comment-author: 'github-actions[bot]'
- name: Create comment
if: steps.fc.outputs.comment-id == ''
uses: peter-evans/create-or-update-comment@v2
with:
issue-number: ${{ steps.get-pr-number.outputs.number }}
body: |
${{ steps.get-comment-body.outputs.body }}
- name: Update comment
if: steps.fc.outputs.comment-id != ''
uses: peter-evans/create-or-update-comment@v2
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
body: |
${{ steps.get-comment-body.outputs.body }}
edit-mode: replace