pages235/.github/workflows/ci.yml
Vitaly Turovsky 0e9fddff8b init
2025-01-14 16:58:16 +07:00

92 lines
2.9 KiB
YAML

name: CI
on:
pull_request:
jobs:
build-and-deploy:
runs-on: ubuntu-latest
permissions: write-all
steps:
- name: Checkout repository
uses: actions/checkout@master
- name: Setup Java JDK
uses: actions/setup-java@v1.4.3
with:
java-version: 17
java-package: jre
- name: Install pnpm
run: npm i -g pnpm@9.0.4
- uses: actions/setup-node@v4
with:
node-version: 18
# cache: "pnpm"
- run: pnpm install
- run: pnpm check-build
- run: pnpm build-playground
- run: pnpm build-storybook
- run: pnpm test-unit
- run: pnpm lint
- run: pnpm tsx scripts/buildNpmReact.ts
- run: nohup pnpm prod-start &
- run: nohup pnpm test-mc-server &
- uses: cypress-io/github-action@v5
with:
install: false
- uses: actions/upload-artifact@v3
if: failure()
with:
name: cypress-images
path: cypress/screenshots/
# - run: node scripts/outdatedGitPackages.mjs
# if: ${{ github.event.pull_request.base.ref == 'release' }}
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Parse Bundle Stats
run: |
SIZE=$(du -sh dist 2>/dev/null | cut -f1)
GZIP_SIZE=$(du -sh dist/**/*.gz 2>/dev/null | cut -f1)
echo "{\"total\": \"$SIZE\", \"gzipped\": \"$GZIP_SIZE\"}" > /tmp/bundle-stats.json
- name: Compare Bundle Stats
id: compare
uses: ./.github/workflows/bundle-stats
with:
mode: compare
branch: ${{ github.event.pull_request.base.ref }}
- name: Store Bundle Stats
if: github.event.pull_request.base.ref == github.event.pull_request.head.ref
uses: ./.github/workflows/bundle-stats
with:
mode: store
branch: ${{ github.event.pull_request.base.ref }}
- name: Update PR Description
uses: actions/github-script@v6
with:
script: |
const { data: pr } = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number
});
let body = pr.body || '';
const statsMarker = '### Bundle Size';
const comparison = '${{ steps.compare.outputs.stats }}';
if (body.includes(statsMarker)) {
body = body.replace(
new RegExp(`${statsMarker}[^\n]*\n[^\n]*`),
`${statsMarker}\n${comparison}`
);
} else {
body += `\n\n${statsMarker}\n${comparison}`;
}
await github.rest.pulls.update({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number,
body
});