diff --git a/.github/workflows/lighthouse_comment.yml b/.github/workflows/lighthouse_comment.yml new file mode 100644 index 00000000..fb1fbb58 --- /dev/null +++ b/.github/workflows/lighthouse_comment.yml @@ -0,0 +1,54 @@ +name: Lighthouse CI + +on: + workflow_dispatch: + +permissions: + contents: read + pull-requests: write + issues: write + +jobs: + lighthouse: + runs-on: ubuntu-latest + + steps: + # 1. Checkout code + - name: Checkout repo + uses: actions/checkout@v4 + + # 2. Setup Node + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: 18 + + # 3. Install dependencies (if needed) + - name: Install dependencies + run: npm install + + # 4. Build project (if React/Vite) + - name: Build project + run: npm run build + + # 5. Run Lighthouse CI + - name: Run Lighthouse CI + uses: treosh/lighthouse-ci-action@v11 + with: + urls: | + https://your-live-site-url.com + uploadArtifacts: true + + # 6. Generate comment file + - name: Create Lighthouse comment + run: | + echo "## 🚀 Lighthouse Report" > lighthouse-comment.md + echo "Check performance report in artifacts." >> lighthouse-comment.md + + # 7. Post comment on PR + - name: Post Lighthouse comment + uses: peter-evans/create-or-update-comment@v4 + with: + issue-number: ${{ github.event.pull_request.number }} + body-path: lighthouse-comment.md + edit-mode: replace