Skip to content

Performance & SEO Check #37

Performance & SEO Check

Performance & SEO Check #37

Workflow file for this run

name: Performance & SEO Check
on:
push:
branches: [ main ]
schedule:
# Run weekly on Sundays at 6:00 AM UTC
- cron: '0 6 * * 0'
workflow_dispatch:
jobs:
lighthouse-check:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.3
bundler-cache: true
- name: Build site
run: |
bundle install
sed -i 's/^baseurl:.*/baseurl: ""/' _config.yml
bundle exec jekyll build
env:
JEKYLL_ENV: production
- name: Setup Node.js for Lighthouse
uses: actions/setup-node@v4
with:
node-version: '18'
- name: Install Lighthouse CI
run: npm install -g @lhci/cli@0.12.x
- name: Serve site locally
run: |
bundle exec jekyll serve --detach --port 4000
sleep 5
- name: Run Lighthouse CI
run: |
lhci autorun --upload.target=temporary-public-storage
env:
LHCI_GITHUB_APP_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Lighthouse report comment
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
try {
const report = fs.readFileSync('.lighthouseci/assertion-results.json', 'utf8');
const results = JSON.parse(report);
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `## 🔍 Lighthouse Performance Report
Performance metrics have been analyzed. Check the Actions tab for detailed results.
Generated by: Performance & SEO Check workflow`
});
} catch (error) {
console.log('Could not find or parse Lighthouse results');
}