Skip to content

Commit 5df99fe

Browse files
ci: fix multiple comments in Lighthouse workflow (#2030)
* ci: fix multiple comments in Lighthouse workflow Signed-off-by: Sebastian Beltran <[email protected]> * fix comment --------- Signed-off-by: Sebastian Beltran <[email protected]> Co-authored-by: shubham oulkar <[email protected]>
1 parent 69c0345 commit 5df99fe

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

.github/workflows/lighthouse.yml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ jobs:
2929
run: |
3030
PREVIEW_URL="https://deploy-preview-${{ github.event.pull_request.number }}--expressjscom-preview.netlify.app"
3131
echo "PREVIEW_URL=$PREVIEW_URL" >> "$GITHUB_ENV"
32-
for i in {1..2}; do
32+
for i in {1..4}; do
3333
if curl -s --head "$PREVIEW_URL" | grep "200 OK" > /dev/null; then
3434
echo "Preview is live!"
3535
break
3636
fi
37-
echo "Waiting for Netlify to deploy... ($i/2)"
37+
echo "Waiting for Netlify to deploy... ($i/4)"
3838
sleep 10
3939
done
4040
@@ -60,6 +60,7 @@ jobs:
6060
6161
npx lighthouse "$url" \
6262
$lighthouse_args \
63+
--only-categories=performance,accessibility,best-practices \
6364
--output json \
6465
--output-path="lighthouse-report-${device}.json" \
6566
--chrome-flags="--headless"
@@ -104,31 +105,32 @@ jobs:
104105
script: |
105106
const fs = require('fs');
106107
const report = fs.readFileSync('lighthouse-report.md', 'utf8');
107-
108+
108109
const { data: comments } = await github.rest.issues.listComments({
109110
issue_number: context.payload.pull_request.number,
110111
owner: context.repo.owner,
111112
repo: context.repo.repo,
112113
});
113-
114+
114115
const botComment = comments.find(comment =>
115-
comment.user.type === 'Bot' &&
116-
comment.body.includes('🚦Lighthouse Results')
116+
comment.user.type === "Bot" &&
117+
comment.body.includes("🚦 Lighthouse Results")
117118
);
118-
119+
119120
if (botComment) {
120121
await github.rest.issues.updateComment({
121122
comment_id: botComment.id,
122123
owner: context.repo.owner,
123124
repo: context.repo.repo,
124-
body: report
125+
body: report,
125126
});
127+
console.log("Updated existing Lighthouse comment.");
126128
} else {
127129
await github.rest.issues.createComment({
128130
issue_number: context.payload.pull_request.number,
129131
owner: context.repo.owner,
130132
repo: context.repo.repo,
131-
body: report
133+
body: report,
132134
});
135+
console.log("Created new Lighthouse comment.");
133136
}
134-

0 commit comments

Comments
 (0)