2021-07-27 14:52:49 -05:00
|
|
|
|
name: Verdaccio Website CI
|
|
|
|
|
|
|
|
|
|
on:
|
|
|
|
|
workflow_dispatch:
|
|
|
|
|
pull_request:
|
2022-08-04 13:04:12 -05:00
|
|
|
|
paths:
|
|
|
|
|
- 'website/**'
|
|
|
|
|
- './.github/workflows/website.yml'
|
2022-09-16 01:11:31 -05:00
|
|
|
|
schedule:
|
|
|
|
|
- cron: '0 0 * * *'
|
2022-10-16 07:06:07 -05:00
|
|
|
|
|
2022-11-12 01:42:01 -05:00
|
|
|
|
permissions:
|
|
|
|
|
contents: read # to fetch code (actions/checkout)
|
|
|
|
|
|
2021-07-27 14:52:49 -05:00
|
|
|
|
jobs:
|
|
|
|
|
build:
|
2022-11-12 01:42:01 -05:00
|
|
|
|
permissions:
|
|
|
|
|
contents: read # to fetch code (actions/checkout)
|
|
|
|
|
deployments: write
|
|
|
|
|
pull-requests: write # to comment on pull-requests
|
|
|
|
|
|
2021-07-27 14:52:49 -05:00
|
|
|
|
runs-on: ubuntu-latest
|
2021-07-27 16:30:02 -05:00
|
|
|
|
env:
|
|
|
|
|
NODE_OPTIONS: --max_old_space_size=4096
|
2021-07-27 14:52:49 -05:00
|
|
|
|
steps:
|
2023-03-27 11:54:32 -05:00
|
|
|
|
- uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # tag=v3
|
2021-07-27 14:52:49 -05:00
|
|
|
|
|
2022-05-19 15:03:04 -05:00
|
|
|
|
- name: Use Node 16
|
2023-01-18 13:35:18 -05:00
|
|
|
|
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # tag=v3
|
2021-07-27 14:52:49 -05:00
|
|
|
|
with:
|
2022-05-19 15:03:04 -05:00
|
|
|
|
node-version: 16
|
2021-07-27 14:52:49 -05:00
|
|
|
|
|
|
|
|
|
- name: Cache pnpm modules
|
2023-03-16 01:31:06 -05:00
|
|
|
|
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3
|
2021-07-27 14:52:49 -05:00
|
|
|
|
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-10-15 14:51:29 -05:00
|
|
|
|
- uses: pnpm/action-setup@c3b53f6a16e57305370b4ae5a540c2077a1d50dd # tag=v2.2.4
|
2021-07-27 14:52:49 -05:00
|
|
|
|
with:
|
2022-05-19 15:03:04 -05:00
|
|
|
|
version: 6.32.15
|
2021-07-27 14:52:49 -05:00
|
|
|
|
run_install: |
|
|
|
|
|
- recursive: true
|
|
|
|
|
args: [--frozen-lockfile]
|
2022-10-10 01:00:09 -05:00
|
|
|
|
- name: Build
|
|
|
|
|
run: pnpm build
|
2022-10-01 07:08:40 -05:00
|
|
|
|
- name: Build Translations percentage
|
|
|
|
|
run: pnpm build --filter "@verdaccio/crowdin-translations"
|
2021-07-27 14:52:49 -05:00
|
|
|
|
- name: Cache Docusaurus Build
|
2023-03-16 01:31:06 -05:00
|
|
|
|
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3
|
2021-07-27 14:52:49 -05:00
|
|
|
|
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 15:39:24 -05:00
|
|
|
|
CROWDIN_VERDACCIO_API_KEY: ${{ secrets.CROWDIN_VERDACCIO_API_KEY }}
|
2022-10-01 07:08:40 -05:00
|
|
|
|
SENTRY_KEY: ${{ secrets.SENTRY_KEY }}
|
2021-07-27 14:52:49 -05: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'
|
2022-08-04 13:34:04 -05:00
|
|
|
|
uses: semoal/action-netlify-deploy@1a53f098745bf78555d11b436f5ee3af87e6b566
|
2021-07-27 14:52:49 -05:00
|
|
|
|
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
|
2022-05-31 12:14:06 -05:00
|
|
|
|
if: github.repository == 'verdaccio/verdaccio'
|
2022-08-04 13:34:04 -05:00
|
|
|
|
uses: semoal/action-netlify-deploy@1a53f098745bf78555d11b436f5ee3af87e6b566
|
2021-07-27 14:52:49 -05:00
|
|
|
|
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
|
2022-05-31 12:14:06 -05:00
|
|
|
|
if: github.repository == 'verdaccio/verdaccio'
|
2021-07-27 14:52:49 -05:00
|
|
|
|
id: lighthouse_audit
|
2023-03-15 01:33:07 -05:00
|
|
|
|
uses: treosh/lighthouse-ci-action@2e159d989f91bb9e399801b3e1ad90bcd4749f75 # tag=9.6.8
|
2021-07-27 14:52:49 -05:00
|
|
|
|
with:
|
|
|
|
|
urls: |
|
|
|
|
|
${{ steps.netlify_preview.outputs.preview-url }}
|
|
|
|
|
uploadArtifacts: true
|
|
|
|
|
temporaryPublicStorage: true
|
|
|
|
|
|
|
|
|
|
- name: Format lighthouse score
|
|
|
|
|
id: format_lighthouse_score
|
2023-04-10 15:31:13 -05:00
|
|
|
|
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # tag=v6
|
2021-07-27 14:52:49 -05:00
|
|
|
|
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
|
2022-05-31 12:14:06 -05:00
|
|
|
|
if: github.repository == 'verdaccio/verdaccio'
|
2021-07-27 14:52:49 -05:00
|
|
|
|
id: comment_to_pr
|
2023-02-14 02:30:56 -05:00
|
|
|
|
uses: marocchino/sticky-pull-request-comment@3d60a5b2dae89d44e0c6ddc69dd7536aec2071cd # tag=v2
|
2021-07-27 14:52:49 -05:00
|
|
|
|
with:
|
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
|
number: ${{ github.event.issue.number }}
|
2022-04-11 15:23:25 -05:00
|
|
|
|
delete: true
|
2021-07-27 14:52:49 -05:00
|
|
|
|
header: lighthouse
|
|
|
|
|
message: |
|
2021-08-12 01:20:54 -05:00
|
|
|
|
${{ steps.format_lighthouse_score.outputs.comment }}
|