diff --git a/.github/workflows/check-node-modules-size.yml b/.github/workflows/check-node-modules-size.yml new file mode 100644 index 0000000..99519bc --- /dev/null +++ b/.github/workflows/check-node-modules-size.yml @@ -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.