Skip to content

Commit

Permalink
ci: check node_modules/ size
Browse files Browse the repository at this point in the history
  • Loading branch information
hamirmahal committed Aug 17, 2023
1 parent 52b2ecd commit 1b669de
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/check-node-modules-size.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Check Node Modules Size

on:
pull_request:
paths:
# `yarn.lock` should no longer be present, but we'll keep this here in case we add it back.
- yarn.lock
- package.json

push:
branches:
- "*"

jobs:
analyze-size:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 18

- name: Install dependencies
run: yarn install

- name: Get main branch node_modules size
id: main_size
run: echo "::set-output name=size::$(du -sh node_modules | awk '{print $1}')"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Analyze node_modules size
id: current_size
run: echo "::set-output name=size::$(du -sh node_modules | awk '{print $1}')"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Compare sizes and send alert
if: ${{ steps.current_size.outputs.size != steps.main_size.outputs.size }}
run: |
echo "Node Modules size has changed!"
echo "Main branch size: ${{ steps.main_size.outputs.size }}"
echo "Current branch size: ${{ steps.current_size.outputs.size }}"
# Add your alerting mechanism here, such as sending a Slack notification, creating an issue, etc.

0 comments on commit 1b669de

Please sign in to comment.