@@ -103,17 +103,34 @@ jobs:
103
103
104
104
- run : echo BENCHES_RESULT=$(cat bench_new.txt) >> $GITHUB_ENV
105
105
106
- # Post comment in case of performance regression or improvement.
107
- - run : npm install fs
108
- - if : contains(env.BENCHES_RESULT, 'regressed') || contains(env.BENCHES_RESULT, 'improved')
109
- uses : actions/github-script@v6
106
+ # Comment with a link to the workflow (or update existing comment on rerun).
107
+ - name : Find Comment
108
+ if : github.event_name == 'pull_request'
109
+ uses : starkware-libs/find-comment@v3
110
+ id : find-benchmark-comment
110
111
with :
111
- script : |
112
- const fs = require('fs')
113
- github.rest.issues.createComment({
114
- issue_number: context.issue.number,
115
- owner: context.repo.owner,
116
- repo: context.repo.repo,
117
- body: fs.readFileSync('bench_new.txt', 'utf8'),
118
- path: 'Commits'
119
- })
112
+ token : ${{ secrets.GITHUB_TOKEN }}
113
+ issue-number : ${{ github.event.pull_request.number }}
114
+ comment-author : ' github-actions[bot]'
115
+ body-includes : Benchmark movements
116
+
117
+ - name : Create comment
118
+ # If the PR number is found and the comment is not found, create a new comment.
119
+ if : github.event_name == 'pull_request'
120
+ && steps.find-benchmark-comment.outputs.comment-id == ''
121
+ uses : starkware-libs/create-or-update-comment@v4
122
+ with :
123
+ token : ${{ secrets.GITHUB_TOKEN }}
124
+ issue-number : ${{ github.event.pull_request.number }}
125
+ body : ${{ env.BENCHES_RESULT }}
126
+
127
+ - name : Update comment
128
+ # If the PR number is found and the comment exists, update it.
129
+ if : github.event_name == 'pull_request'
130
+ && steps.find-benchmark-comment.outputs.comment-id != ''
131
+ uses : starkware-libs/create-or-update-comment@v4
132
+ with :
133
+ token : ${{ secrets.GITHUB_TOKEN }}
134
+ comment-id : ${{ steps.find-benchmark-comment.outputs.comment-id }}
135
+ edit-mode : replace
136
+ body : ${{ env.BENCHES_RESULT }}
0 commit comments