Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions .github/workflows/lighthouse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ jobs:
run: |
PREVIEW_URL="https://deploy-preview-${{ github.event.pull_request.number }}--expressjscom-preview.netlify.app"
echo "PREVIEW_URL=$PREVIEW_URL" >> "$GITHUB_ENV"
for i in {1..2}; do
for i in {1..4}; do
if curl -s --head "$PREVIEW_URL" | grep "200 OK" > /dev/null; then
echo "Preview is live!"
break
fi
echo "Waiting for Netlify to deploy... ($i/2)"
echo "Waiting for Netlify to deploy... ($i/4)"
sleep 10
done

Expand All @@ -60,6 +60,7 @@ jobs:

npx lighthouse "$url" \
$lighthouse_args \
--only-categories=performance,accessibility,best-practices \
--output json \
--output-path="lighthouse-report-${device}.json" \
--chrome-flags="--headless"
Expand Down Expand Up @@ -104,31 +105,32 @@ jobs:
script: |
const fs = require('fs');
const report = fs.readFileSync('lighthouse-report.md', 'utf8');

const { data: comments } = await github.rest.issues.listComments({
issue_number: context.payload.pull_request.number,
owner: context.repo.owner,
repo: context.repo.repo,
});

const botComment = comments.find(comment =>
comment.user.type === 'Bot' &&
comment.body.includes('🚦Lighthouse Results')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This space causing issue

comment.user.type === "Bot" &&
comment.body.includes("🚦 Lighthouse Results")
);

if (botComment) {
await github.rest.issues.updateComment({
comment_id: botComment.id,
owner: context.repo.owner,
repo: context.repo.repo,
body: report
body: report,
});
console.log("Updated existing Lighthouse comment.");
} else {
await github.rest.issues.createComment({
issue_number: context.payload.pull_request.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: report
body: report,
});
console.log("Created new Lighthouse comment.");
}