Website Regression #85
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: Website Regression | |
| on: | |
| pull_request: | |
| branches: [ main, master, develop ] | |
| push: | |
| branches: [ main, master, develop ] | |
| jobs: | |
| lighthouse: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 18 | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Install Chrome | |
| uses: browser-actions/setup-chrome@v1 | |
| with: | |
| chrome-version: stable | |
| - name: Run Lighthouse CI | |
| env: | |
| LHCI_GITHUB_APP_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: npm run website:test | |
| - name: Create GitHub issue on Lighthouse regression | |
| if: failure() | |
| uses: actions/github-script@v6 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| const title = `🚨 Lighthouse regression detected in ${context.sha}`; | |
| const body = `Automatic website-regression workflow failed due to Lighthouse scores below the required thresholds (95/90).\n\nRefer to the failed workflow run for trace artifacts.`; | |
| const { owner, repo } = context.repo; | |
| const search = await github.search.issuesAndPullRequests({ | |
| q: `repo:${owner}/${repo} in:title "${title}"` | |
| }); | |
| if (search.data.total_count === 0) { | |
| await github.issues.create({ | |
| owner, | |
| repo, | |
| title, | |
| body, | |
| labels: ['lighthouse', 'blocking'] | |
| }); | |
| } else { | |
| console.log('Lighthouse regression issue already exists'); | |
| } |