Skip to content

Commit

Permalink
Update comment job to use github-script action
Browse files Browse the repository at this point in the history
  • Loading branch information
KshitijThareja committed Aug 9, 2024
1 parent bf8a172 commit 10a1d40
Showing 1 changed file with 39 additions and 11 deletions.
50 changes: 39 additions & 11 deletions .github/workflows/visual_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,22 +64,50 @@ jobs:
if: ${{ needs.visual_tests.result == 'success' }}
runs-on: ubuntu-latest
steps:
- name: Post results comment
uses: thollander/actions-comment-pull-request@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
message: |
### Percy Visual Test Results
- name: Define comment body
run: |
echo "### Percy Visual Test Results
**Percy Dashboard:** [View Detailed Report](${{ needs.visual_tests.outputs.percy_url }})
**Environment:**
- **Node.js Version:** 18.x
- **OS:** Ubuntu-latest
**Instructions for Reviewers:**
- Click on the [Percy Dashboard](${{ needs.visual_tests.outputs.percy_url }}) link to view detailed visual diffs.
- Review the visual changes highlighted in the report.
- Approve or request changes based on the visual differences.
comment_tag: execution
mode: recreate
- Approve or request changes based on the visual differences." > comment_body.md
- name: Create or update comment
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs');
const commentBody = fs.readFileSync('comment_body.md', 'utf8');
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number
});
const comment = comments.find(comment => comment.body.includes('### Percy Visual Test Results'));
if (comment) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: comment.id,
body: commentBody
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: commentBody
});
}

0 comments on commit 10a1d40

Please sign in to comment.