build(deps): standardize dependabot config and enable auto-merge (#93) #35
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Lighthouse CI | |
| on: | |
| pull_request: | |
| push: | |
| branches: [main] | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| jobs: | |
| lighthouse: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - uses: taiki-e/install-action@5939f3337e40968c39aa70f5ecb1417a92fb25a0 # v2.75.15 | |
| with: | |
| tool: just | |
| - name: Setup Node.js | |
| uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0 | |
| with: | |
| node-version: 'lts/*' | |
| - name: Run Lighthouse | |
| id: lighthouse | |
| run: just lighthouse | |
| - name: Upload Lighthouse HTML reports | |
| if: always() | |
| uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 | |
| with: | |
| name: lighthouse-reports | |
| path: /tmp/lighthouse-*.report.html | |
| retention-days: 14 | |
| - name: Load results for PR comment | |
| if: always() && github.event_name == 'pull_request' | |
| run: | | |
| echo "LIGHTHOUSE_RESULTS<<EOF" >> $GITHUB_ENV | |
| cat /tmp/lighthouse-results.md >> $GITHUB_ENV | |
| echo "EOF" >> $GITHUB_ENV | |
| - name: Comment on pull request with results | |
| if: always() && github.event_name == 'pull_request' | |
| uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 | |
| with: | |
| script: | | |
| const fs = require("fs"); | |
| const results = process.env.LIGHTHOUSE_RESULTS || "No results available"; | |
| const status = '${{ steps.lighthouse.outcome }}' === 'success' ? '✅ PASSED' : '⚠️ NEEDS IMPROVEMENT'; | |
| const template = fs.readFileSync(".github/comment-templates/lighthouse-report.md", "utf8"); | |
| const body = template.replace("{{status}}", status).replace("{{results}}", results); | |
| const marker = "<!-- lighthouse-report -->"; | |
| const bodyWithMarker = marker + "\n" + body; | |
| const { data: comments } = await github.rest.issues.listComments({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| }); | |
| const existing = comments.find(c => c.body.includes(marker)); | |
| if (existing) { | |
| await github.rest.issues.updateComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| comment_id: existing.id, | |
| body: bodyWithMarker, | |
| }); | |
| } else { | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| body: bodyWithMarker, | |
| }); | |
| } |