This repository has been archived by the owner on Jul 23, 2024. It is now read-only.
new home reference #1497
Workflow file for this run
This file contains 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: Continuous Integration | |
on: | |
pull_request: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
jobs: | |
check: | |
runs-on: ubuntu-latest | |
if: "! contains(github.event.head_commit.message, '[CI Skip]')" | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup node | |
uses: actions/setup-node@v3 | |
- name: Install | |
run: yarn install --immutable --immutable-cache --check-cache | |
- name: Checks | |
run: yarn check:all | |
- name: Audit | |
run: yarn | |
continue-on-error: true | |
- name: Test | |
run: yarn test:unit | |
# Continuously deploys the content of main branch | |
deploy: | |
runs-on: ubuntu-latest | |
needs: check | |
if: github.event_name == 'push' | |
permissions: | |
pages: write | |
id-token: write | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup node | |
uses: actions/setup-node@v3 | |
- name: Install | |
run: yarn install --immutable --immutable-cache --check-cache | |
- name: Setup Pages | |
id: pages | |
uses: actions/configure-pages@v3 | |
- name: Build | |
run: yarn build | |
env: | |
PUBLIC_URL: ${{ steps.pages.outputs.base_url }} | |
- name: Upload artifact | |
# Automatically uploads an artifact from the './_site' directory by default | |
uses: actions/upload-pages-artifact@v1 | |
with: | |
path: dist/ | |
retention-days: 10 | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v2 | |
- name: Audit URLs using Lighthouse | |
uses: treosh/lighthouse-ci-action@v10 | |
id: lighthouse | |
with: | |
urls: | | |
${{ steps.pages.outputs.base_url }} | |
# See https://github.com/GoogleChrome/budget.json | |
budgetPath: .github/workflows/budget.json | |
- name: Format lighthouse score | |
id: lighthouse-score | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const result = ${{ steps.lighthouse.outputs.manifest }}[0].summary; | |
const formatResult = (res) => Math.round((res * 100)); | |
Object.keys(result).forEach(key => result[key] = formatResult(result[key])); | |
const score = res => res >= 90 ? '🟢' : res >= 50 ? '🟠' : '🔴'; | |
const comment = [ | |
`⚡️ Lighthouse report for the changes in this PR:`, | |
'| Category | Score |', | |
'| --- | --- |', | |
`| ${score(result.performance)} Performance | ${result.performance} |`, | |
`| ${score(result.accessibility)} Accessibility | ${result.accessibility} |`, | |
`| ${score(result['best-practices'])} Best practices | ${result['best-practices']} |`, | |
`| ${score(result.seo)} SEO | ${result.seo} |`, | |
`| ${score(result.pwa)} PWA | ${result.pwa} |` | |
].join('\n'); | |
core.setOutput("comment", comment); | |
- name: Add comment to PR | |
uses: marocchino/sticky-pull-request-comment@v2 | |
with: | |
header: lighthouse | |
message: | | |
${{ steps.lighthouse-score.outputs.comment }} |