-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIX]: Update PR Comment, with github-script (#445)
- Loading branch information
Showing
1 changed file
with
25 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,16 +43,32 @@ jobs: | |
path: benchmark-reports.tgz | ||
retention-days: 30 | ||
|
||
- name: PR Comment | ||
uses: github-actions-up-and-running/[email protected] | ||
if: ${{ github.event_name == 'pull_request' }} | ||
- name: Comment PR | ||
if: github.event_name == 'pull_request' | ||
uses: actions/github-script@v6 | ||
with: | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
message: | | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
const issue_number = context.issue.number; | ||
const owner = context.repo.owner; | ||
const repo = context.repo.repo; | ||
const contentWithLineNumbers = `${process.env.BENCHMARK_REPORT}` | ||
.split('\n') | ||
.map((line, idx) => `${idx + 1}. ${line}`) | ||
.join('\n'); | ||
const body = ` | ||
<details> | ||
<summary>BENCHMARK_REPORT</summary> | ||
``` | ||
${{ env.BENCHMARK_REPORT }} | ||
``` | ||
<pre style="display:block; white-space:pre-wrap; background-color: #f5f5f5; padding: 10px; border: 1px solid #ccc; border-radius: 4px; font-family: monospace;"> | ||
${contentWithLineNumbers} | ||
</pre> | ||
</details> | ||
`; | ||
github.rest.issues.createComment({ | ||
issue_number, | ||
owner, | ||
repo, | ||
body | ||
}); |