Bump semver from 5.7.1 to 5.7.2 #10
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: Pull Request Deploy and Audit | |
on: [pull_request] | |
jobs: | |
deploy_and_audit: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Setup NPM | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "16.x" | |
- name: Install Dependency | |
run: npm install -f | |
- name: Run npm build | |
run: npm run build | |
- name: Add comment to PR | |
id: loading_lighthouse_comment_to_pr | |
uses: marocchino/sticky-pull-request-comment@v2 | |
with: | |
GITHUB_TOKEN: ${{ secrets.GH_TOKEN_PR }} | |
number: ${{ github.event.pull_request.number }} | |
header: lighthouse | |
message: | | |
🚦 Running Lighthouse audit... | |
- name: Add comment to PR | |
id: loading_budget_comment_to_pr | |
uses: marocchino/sticky-pull-request-comment@v2 | |
with: | |
GITHUB_TOKEN: ${{ secrets.GH_TOKEN_PR }} | |
number: ${{ github.event.pull_request.number }} | |
header: budget | |
message: | | |
⏱ Running budget checks... | |
- name: Audit URLs using Lighthouse | |
id: lighthouse_audit | |
uses: treosh/lighthouse-ci-action@v7 | |
with: | |
budgetPath: '.github/lighthouse/budget.json' | |
configPath: '.github/lighthouse/lighthouserc.json' | |
uploadArtifacts: true | |
temporaryPublicStorage: true | |
- name: Format lighthouse result | |
id: lighthouse_result | |
if: ${{ always() }} | |
uses: actions/github-script@v4 | |
with: | |
github-token: ${{secrets.GH_TOKEN_PR}} | |
script: | | |
const links = ${{ steps.lighthouse_audit.outputs.links }} | |
const results = (${{ steps.lighthouse_audit.outputs.manifest }}).filter(result => result.isRepresentativeRun); | |
const score = res => res >= 90 ? '🟢' : res >= 50 ? '🟠' : '🔴'; | |
const comment = results.map((result) => { | |
const summary = result.summary; | |
const url = result.url; | |
return ` | |
🌎 [${url}](${url}) | |
⚡️ [Lighthouse report](${links[url]}) | |
| Category | Score | | |
| --- | --- | | |
${Object.keys(summary).map((key) => { | |
const percentage = Math.round(summary[key] * 100); | |
return `| ${score(percentage)} ${key} | ${percentage} |`; | |
}).join('\n')} | |
`; | |
}).join('---'); | |
core.setOutput("comment", comment); | |
- name: Format budget result | |
id: budget_result | |
if: ${{ always() }} | |
uses: actions/github-script@v4 | |
with: | |
github-token: ${{secrets.GH_TOKEN_PR}} | |
script: | | |
const assertions = ${{ steps.lighthouse_audit.outputs.assertionResults }}; | |
if (!assertions.length) { | |
core.setOutput("comment", '✅ Budget met, nothing to see here'); | |
} else { | |
const comment = assertions.map((result) => { | |
return ` | |
❌ **${result.auditProperty || ''}.${result.auditId}** failure on [${result.url}](${result.url}) | |
*${result.auditTitle}* - [docs](${result.auditDocumentationLink}) | |
| Actual | Expected | | |
| --- | --- | | |
| ${result.actual} | ${result.operator} ${result.expected} | | |
`; | |
}).join('---'); | |
core.setOutput("comment", comment); | |
} | |
- name: Add Lighthouse comment to PR | |
id: lighthouse_comment_to_pr | |
if: ${{ always() }} | |
uses: marocchino/sticky-pull-request-comment@v1 | |
with: | |
GITHUB_TOKEN: ${{ secrets.GH_TOKEN_PR }} | |
number: ${{ github.event.pull_request.number }} | |
header: lighthouse | |
message: | | |
${{ steps.lighthouse_result.outputs.comment }} | |
- name: Add Budget comment to PR | |
id: budget_comment_to_pr | |
if: ${{ always() }} | |
uses: marocchino/sticky-pull-request-comment@v1 | |
with: | |
GITHUB_TOKEN: ${{ secrets.GH_TOKEN_PR }} | |
number: ${{ github.event.pull_request.number }} | |
header: budget | |
message: | | |
${{ steps.budget_result.outputs.comment }} |