Skip to content

Commit

Permalink
Merge pull request #298 from lincc-frameworks/issue/297/update-benchm…
Browse files Browse the repository at this point in the history
…ark-comment

Update existing benchmark comment on pull request
  • Loading branch information
camposandro authored Oct 9, 2023
2 parents c7f763c + f898d41 commit 4cfd383
Showing 1 changed file with 14 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,24 +84,18 @@ jobs:
env:
STEP_URL: "{% raw %}${{ steps.jobs.outputs.html_url }}{% endraw %}#step:8:1"

- name: Publish comment to PR
uses: actions/github-script@v6
- name: Find benchmarks comment
uses: peter-evans/find-comment@v2
id: find-comment
with:
github-token: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %}
script: |
const fs = require('fs');
const path = require('path');

const workingDir = process.env.WORKING_DIR;
try {
process.chdir(workingDir);
const comment = fs.readFileSync('output', 'utf-8');
const { data } = await github.rest.issues.createComment({
...context.repo,
issue_number: context.issue.number,
body: comment,
});
console.log('Comment published:', data.html_url);
} catch (err) {
console.error(err);
}
issue-number: {% raw %}${{ github.event.pull_request.number }}{% endraw %}
comment-author: 'github-actions[bot]'
body-includes: view all benchmarks

- name: Create or update benchmarks comment
uses: peter-evans/create-or-update-comment@v3
with:
comment-id: {% raw %}${{ steps.find-comment.outputs.comment-id }}{% endraw %}
issue-number: {% raw %}${{ github.event.pull_request.number }}{% endraw %}
body-path: {% raw %}${{ env.WORKING_DIR }}/output{% endraw %}
edit-mode: replace

0 comments on commit 4cfd383

Please sign in to comment.