2021-07-27 21:52:49 +02:00
|
|
|
|
name: Verdaccio Website CI
|
|
|
|
|
|
|
|
|
|
on:
|
|
|
|
|
workflow_dispatch:
|
|
|
|
|
pull_request:
|
2022-08-04 20:04:12 +02:00
|
|
|
|
paths:
|
|
|
|
|
- 'website/**'
|
|
|
|
|
- './.github/workflows/website.yml'
|
2022-09-16 08:11:31 +02:00
|
|
|
|
schedule:
|
|
|
|
|
- cron: '0 0 * * *'
|
2022-10-16 14:06:07 +02:00
|
|
|
|
|
2022-11-12 07:42:01 +01:00
|
|
|
|
permissions:
|
|
|
|
|
contents: read # to fetch code (actions/checkout)
|
|
|
|
|
|
2021-07-27 21:52:49 +02:00
|
|
|
|
jobs:
|
|
|
|
|
build:
|
2022-11-12 07:42:01 +01:00
|
|
|
|
permissions:
|
|
|
|
|
contents: read # to fetch code (actions/checkout)
|
|
|
|
|
deployments: write
|
|
|
|
|
pull-requests: write # to comment on pull-requests
|
|
|
|
|
|
2021-07-27 21:52:49 +02:00
|
|
|
|
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:
|
2023-10-10 18:24:51 +02:00
|
|
|
|
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
|
2021-07-27 21:52:49 +02:00
|
|
|
|
|
2023-11-29 20:00:58 +01:00
|
|
|
|
- name: Node
|
2023-10-30 20:06:46 +01:00
|
|
|
|
uses: actions/setup-node@1a4442cacd436585916779262731d5b162bc6ec7 # v3
|
2021-07-27 21:52:49 +02:00
|
|
|
|
with:
|
2023-11-29 20:00:58 +01:00
|
|
|
|
node-version-file: '.nvmrc'
|
|
|
|
|
- name: Install pnpm
|
|
|
|
|
run: |
|
|
|
|
|
corepack enable
|
|
|
|
|
corepack install
|
2023-11-29 20:06:23 +01:00
|
|
|
|
- name: set store
|
|
|
|
|
run: |
|
|
|
|
|
mkdir ~/.pnpm-store
|
|
|
|
|
pnpm config set store-dir ~/.pnpm-store
|
2023-11-29 20:02:58 +01:00
|
|
|
|
- name: Install
|
|
|
|
|
run: pnpm install --registry http://localhost:4873
|
|
|
|
|
- name: Cache .pnpm-store
|
|
|
|
|
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3
|
|
|
|
|
with:
|
|
|
|
|
path: ~/.pnpm-store
|
|
|
|
|
key: pnpm-${{ hashFiles('pnpm-lock.yaml') }}
|
|
|
|
|
restore-keys: |
|
|
|
|
|
pnpm-
|
2022-10-10 08:00:09 +02:00
|
|
|
|
- name: Build
|
|
|
|
|
run: pnpm build
|
2022-10-01 14:08:40 +02:00
|
|
|
|
- name: Build Translations percentage
|
2023-04-12 17:55:39 +02:00
|
|
|
|
run: pnpm --filter @verdaccio/crowdin-translations build
|
2021-07-27 21:52:49 +02:00
|
|
|
|
- name: Cache Docusaurus Build
|
2023-03-16 07:31:06 +01:00
|
|
|
|
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3
|
2021-07-27 21:52:49 +02: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 22:39:24 +02:00
|
|
|
|
CROWDIN_VERDACCIO_API_KEY: ${{ secrets.CROWDIN_VERDACCIO_API_KEY }}
|
2022-10-01 14:08:40 +02:00
|
|
|
|
SENTRY_KEY: ${{ secrets.SENTRY_KEY }}
|
2021-07-27 21:52:49 +02:00
|
|
|
|
CONTEXT: production
|
2023-04-12 19:31:22 +02:00
|
|
|
|
run: pnpm --filter @verdaccio/website netlify:build:production
|
2021-07-27 21:52:49 +02:00
|
|
|
|
|
|
|
|
|
- name: 🔥 Deploy Production Netlify
|
|
|
|
|
if: (github.event_name == 'push' && github.ref == 'refs/heads/master') || github.event_name == 'workflow_dispatch'
|
2022-08-04 20:34:04 +02:00
|
|
|
|
uses: semoal/action-netlify-deploy@1a53f098745bf78555d11b436f5ee3af87e6b566
|
2021-07-27 21:52:49 +02: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
|
2023-04-17 07:14:00 +02:00
|
|
|
|
run: pnpm --filter ...@verdaccio/website netlify:build:deployPreview
|
2021-07-27 21:52:49 +02:00
|
|
|
|
|
|
|
|
|
- name: 🤖 Deploy Preview Netlify
|
2022-05-31 19:14:06 +02:00
|
|
|
|
if: github.repository == 'verdaccio/verdaccio'
|
2022-08-04 20:34:04 +02:00
|
|
|
|
uses: semoal/action-netlify-deploy@1a53f098745bf78555d11b436f5ee3af87e6b566
|
2021-07-27 21:52:49 +02: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 19:14:06 +02:00
|
|
|
|
if: github.repository == 'verdaccio/verdaccio'
|
2021-07-27 21:52:49 +02:00
|
|
|
|
id: lighthouse_audit
|
2023-04-24 17:24:39 +02:00
|
|
|
|
uses: treosh/lighthouse-ci-action@03becbfc543944dd6e7534f7ff768abb8a296826 # tag=10.1.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
|
2023-11-27 18:12:27 +01:00
|
|
|
|
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6
|
2021-07-27 21:52:49 +02: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 19:14:06 +02:00
|
|
|
|
if: github.repository == 'verdaccio/verdaccio'
|
2021-07-27 21:52:49 +02:00
|
|
|
|
id: comment_to_pr
|
2023-08-21 20:12:36 +02:00
|
|
|
|
uses: marocchino/sticky-pull-request-comment@efaaab3fd41a9c3de579aba759d2552635e590fd # v2
|
2021-07-27 21:52:49 +02:00
|
|
|
|
with:
|
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
|
number: ${{ github.event.issue.number }}
|
2022-04-11 22:23:25 +02:00
|
|
|
|
delete: true
|
2021-07-27 21:52:49 +02:00
|
|
|
|
header: lighthouse
|
|
|
|
|
message: |
|
2021-08-12 08:20:54 +02:00
|
|
|
|
${{ steps.format_lighthouse_score.outputs.comment }}
|