mirror of
https://github.com/verdaccio/verdaccio.git
synced 2024-12-16 21:56:25 -05:00
6aa30f8bf9
Bumps [actions/checkout](https://github.com/actions/checkout) from 3.2.0 to 3.3.0.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](755da8c3cf...ac59398561
)
---
updated-dependencies:
- dependency-name: actions/checkout
dependency-type: direct:production
update-type: version-update:semver-minor
...
Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
144 lines
5.9 KiB
YAML
144 lines
5.9 KiB
YAML
name: Verdaccio Website CI
|
||
|
||
on:
|
||
workflow_dispatch:
|
||
pull_request:
|
||
paths:
|
||
- 'website/**'
|
||
- './.github/workflows/website.yml'
|
||
schedule:
|
||
- cron: '0 0 * * *'
|
||
|
||
permissions:
|
||
contents: read # to fetch code (actions/checkout)
|
||
|
||
jobs:
|
||
build:
|
||
permissions:
|
||
contents: read # to fetch code (actions/checkout)
|
||
deployments: write
|
||
pull-requests: write # to comment on pull-requests
|
||
|
||
runs-on: ubuntu-latest
|
||
env:
|
||
NODE_OPTIONS: --max_old_space_size=4096
|
||
steps:
|
||
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # tag=v3
|
||
|
||
- name: Use Node 16
|
||
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # tag=v3
|
||
with:
|
||
node-version: 16
|
||
|
||
- name: Cache pnpm modules
|
||
uses: actions/cache@58c146cc91c5b9e778e71775dfe9bf1442ad9a12 # v3
|
||
env:
|
||
cache-name: cache-pnpm-modules
|
||
with:
|
||
path: ~/.pnpm-store
|
||
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ matrix.node-version }}-${{ hashFiles('**/pnpm-lock.yaml') }}
|
||
restore-keys: |
|
||
${{ runner.os }}-build-${{ env.cache-name }}-${{ matrix.node-version }}-
|
||
|
||
- uses: pnpm/action-setup@c3b53f6a16e57305370b4ae5a540c2077a1d50dd # tag=v2.2.4
|
||
with:
|
||
version: 6.32.15
|
||
run_install: |
|
||
- recursive: true
|
||
args: [--frozen-lockfile]
|
||
- name: Build
|
||
run: pnpm build
|
||
- name: Build Translations percentage
|
||
run: pnpm build --filter "@verdaccio/crowdin-translations"
|
||
- name: Cache Docusaurus Build
|
||
uses: actions/cache@58c146cc91c5b9e778e71775dfe9bf1442ad9a12 # v3
|
||
with:
|
||
path: website/node_modules/.cache/webpack
|
||
key: cache/webpack-${{github.ref}}-${{ hashFiles('**/pnpm-lock.yaml') }}
|
||
restore-keys: cache/webpack-${{github.ref}}
|
||
|
||
# Will deploy to production on:
|
||
# 1st: When a push occurs on master branch
|
||
# 2nd: When we force the worflow dispatch through the UI
|
||
- name: Build Production
|
||
if: (github.event_name == 'push' && github.ref == 'refs/heads/master') || github.event_name == 'workflow_dispatch'
|
||
env:
|
||
CROWDIN_VERDACCIO_API_KEY: ${{ secrets.CROWDIN_VERDACCIO_API_KEY }}
|
||
SENTRY_KEY: ${{ secrets.SENTRY_KEY }}
|
||
CONTEXT: production
|
||
run: pnpm netlify:build:production --filter ...@verdaccio/website
|
||
|
||
- name: 🔥 Deploy Production Netlify
|
||
if: (github.event_name == 'push' && github.ref == 'refs/heads/master') || github.event_name == 'workflow_dispatch'
|
||
uses: semoal/action-netlify-deploy@1a53f098745bf78555d11b436f5ee3af87e6b566
|
||
with:
|
||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||
netlify-auth-token: ${{ secrets.NETLIFY_AUTH_TOKEN }}
|
||
netlify-site-id: ${{ secrets.NETLIFY_SITE_ID }}
|
||
build-dir: './website/build'
|
||
|
||
# Will deploy to Preview URL, only when a pull request is open with changes on the website
|
||
- name: Build Deployment Preview
|
||
env:
|
||
CONTEXT: deploy-preview
|
||
run: pnpm netlify:build:deployPreview --filter ...@verdaccio/website
|
||
|
||
- name: 🤖 Deploy Preview Netlify
|
||
if: github.repository == 'verdaccio/verdaccio'
|
||
uses: semoal/action-netlify-deploy@1a53f098745bf78555d11b436f5ee3af87e6b566
|
||
id: netlify_preview
|
||
with:
|
||
draft: true
|
||
comment-on-pull-request: true
|
||
github-deployment-is-production: false
|
||
github-deployment-is-transient: true
|
||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||
netlify-auth-token: ${{ secrets.NETLIFY_AUTH_TOKEN }}
|
||
netlify-site-id: ${{ secrets.NETLIFY_SITE_ID }}
|
||
build-dir: './website/build'
|
||
|
||
- name: Audit preview URL with Lighthouse
|
||
if: github.repository == 'verdaccio/verdaccio'
|
||
id: lighthouse_audit
|
||
uses: treosh/lighthouse-ci-action@e0fe113967eee84b631d526ed18ce001f35fe9e9 # tag=9.3.1
|
||
with:
|
||
urls: |
|
||
${{ steps.netlify_preview.outputs.preview-url }}
|
||
uploadArtifacts: true
|
||
temporaryPublicStorage: true
|
||
|
||
- name: Format lighthouse score
|
||
id: format_lighthouse_score
|
||
uses: actions/github-script@d556feaca394842dc55e4734bf3bb9f685482fa0 # tag=v6
|
||
with:
|
||
github-token: ${{secrets.GITHUB_TOKEN}}
|
||
script: |
|
||
const result = ${{ steps.lighthouse_audit.outputs.manifest }}[0].summary
|
||
const links = ${{ steps.lighthouse_audit.outputs.links }}
|
||
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](${Object.values(links)[0]}) 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} |`,
|
||
' ',
|
||
`*Lighthouse ran on [${Object.keys(links)[0]}](${Object.keys(links)[0]})*`
|
||
].join('\n')
|
||
core.setOutput("comment", comment);
|
||
|
||
- name: Add comment to PR
|
||
if: github.repository == 'verdaccio/verdaccio'
|
||
id: comment_to_pr
|
||
uses: marocchino/sticky-pull-request-comment@fcf6fe9e4a0409cd9316a5011435be0f3327f1e1 # tag=v2
|
||
with:
|
||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||
number: ${{ github.event.issue.number }}
|
||
delete: true
|
||
header: lighthouse
|
||
message: |
|
||
${{ steps.format_lighthouse_score.outputs.comment }}
|