2021-07-27 21:52:49 +02:00
|
|
|
|
name: Verdaccio Website CI
|
|
|
|
|
|
|
|
|
|
on:
|
|
|
|
|
workflow_dispatch:
|
|
|
|
|
pull_request:
|
|
|
|
|
types:
|
|
|
|
|
- opened
|
|
|
|
|
- synchronize
|
|
|
|
|
paths:
|
|
|
|
|
- 'website/**'
|
|
|
|
|
- 'package.json'
|
2021-07-27 23:30:02 +02:00
|
|
|
|
- './.github/workflows/website.yml'
|
2021-07-27 21:52:49 +02:00
|
|
|
|
push:
|
|
|
|
|
branches:
|
|
|
|
|
- 'master'
|
|
|
|
|
paths:
|
|
|
|
|
- 'website/**'
|
|
|
|
|
- 'package.json'
|
2021-07-27 23:30:02 +02:00
|
|
|
|
- './.github/workflows/website.yml'
|
2021-07-27 21:52:49 +02:00
|
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
|
build:
|
|
|
|
|
runs-on: ubuntu-latest
|
2021-07-27 23:30:02 +02:00
|
|
|
|
env:
|
|
|
|
|
NODE_OPTIONS: --max_old_space_size=4096
|
2021-07-27 21:52:49 +02:00
|
|
|
|
steps:
|
2021-11-06 15:58:24 +01:00
|
|
|
|
- uses: actions/checkout@v2.4.0
|
2021-07-27 21:52:49 +02:00
|
|
|
|
|
|
|
|
|
- name: Use Node 14
|
2022-03-02 22:41:55 +01:00
|
|
|
|
uses: actions/setup-node@v3
|
2021-07-27 21:52:49 +02:00
|
|
|
|
with:
|
|
|
|
|
node-version: 14
|
|
|
|
|
|
|
|
|
|
- name: Cache pnpm modules
|
|
|
|
|
uses: actions/cache@v2
|
|
|
|
|
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 }}-
|
|
|
|
|
|
2022-03-05 09:32:33 +01:00
|
|
|
|
- uses: pnpm/action-setup@v2.2.1
|
2021-07-27 21:52:49 +02:00
|
|
|
|
with:
|
|
|
|
|
version: 6.10.2
|
|
|
|
|
run_install: |
|
|
|
|
|
- recursive: true
|
|
|
|
|
args: [--frozen-lockfile]
|
2021-12-01 08:20:39 +01:00
|
|
|
|
- name: Build Plugins
|
|
|
|
|
run: pnpm build --filter "docusaurus-plugin-contributors"
|
2021-07-27 21:52:49 +02:00
|
|
|
|
- name: Cache Docusaurus Build
|
|
|
|
|
uses: actions/cache@v2
|
|
|
|
|
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:
|
2021-07-27 22:39:24 +02:00
|
|
|
|
CROWDIN_VERDACCIO_PROJECT_ID: ${{ secrets.CROWDIN_VERDACCIO_PROJECT_ID }}
|
|
|
|
|
CROWDIN_VERDACCIO_API_KEY: ${{ secrets.CROWDIN_VERDACCIO_API_KEY }}
|
2021-07-27 21:52:49 +02:00
|
|
|
|
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@master
|
|
|
|
|
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
|
|
|
|
|
uses: semoal/action-netlify-deploy@master
|
|
|
|
|
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
|
|
|
|
|
id: lighthouse_audit
|
2022-03-04 19:22:02 +01:00
|
|
|
|
uses: treosh/lighthouse-ci-action@9.3.0
|
2021-07-27 21:52:49 +02:00
|
|
|
|
with:
|
|
|
|
|
urls: |
|
|
|
|
|
${{ steps.netlify_preview.outputs.preview-url }}
|
|
|
|
|
uploadArtifacts: true
|
|
|
|
|
temporaryPublicStorage: true
|
|
|
|
|
|
|
|
|
|
- name: Format lighthouse score
|
|
|
|
|
id: format_lighthouse_score
|
|
|
|
|
uses: actions/github-script@v3
|
|
|
|
|
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
|
|
|
|
|
id: comment_to_pr
|
|
|
|
|
uses: marocchino/sticky-pull-request-comment@v1
|
|
|
|
|
with:
|
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
|
number: ${{ github.event.issue.number }}
|
|
|
|
|
header: lighthouse
|
|
|
|
|
message: |
|
2021-08-12 08:20:54 +02:00
|
|
|
|
${{ steps.format_lighthouse_score.outputs.comment }}
|