Skip to content

Commit

Permalink
Migrate findComment and generateComment functions to githubUtils.js
Browse files Browse the repository at this point in the history
  • Loading branch information
KshitijThareja committed Aug 13, 2024
1 parent 0ff28b9 commit d536c84
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
11 changes: 3 additions & 8 deletions .github/githubUtils.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
const fs = require('fs');
const path = require('path');

async function generateComment(github, context) {
const percyUrl = context.outputs.percy_url;

return `
async function generateComment(percyUrl) {
return `
### Percy Visual Test Results
**Percy Dashboard:** [View Detailed Report](${percyUrl})
Expand Down Expand Up @@ -45,4 +40,4 @@ async function findComment(github, context, issue_number) {
module.exports = {
findComment,
generateComment,
}
}
9 changes: 7 additions & 2 deletions .github/workflows/visual_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,18 @@ jobs:
if: ${{ needs.visual_tests.result == 'success' }}
runs-on: ubuntu-latest
steps:
- name: Checkout code from PR
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Define comment body
id: comment-text
uses: actions/github-script@v7
with:
script: |
const percyUrl = "${{ needs.visual_tests.outputs.percy_url }}";
const utils = require('./.github/githubUtils.js');
return await utils.generateComment(github, context);
return await utils.generateComment(percyUrl);
- name: Find existing comment
id: find-comment
uses: actions/github-script@v7
Expand Down Expand Up @@ -101,4 +106,4 @@ jobs:
repo: context.repo.repo,
comment_id: ${{steps.find-comment.outputs.result}},
body: ${{ steps.comment-text.outputs.result }}
})
})

0 comments on commit d536c84

Please sign in to comment.