Skip to content

Jackw/bundle size workflow #11

Jackw/bundle size workflow

Jackw/bundle size workflow #11

Workflow file for this run

name: Bundle Stats
on:
pull_request:
branches:
- main
permissions:
contents: write
pull-requests: write
actions: read
jobs:
compare:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '16'
cache: 'npm'
- name: Get main stats artifact run-id
id: 'main-stats-info'
run: |
MAIN_STATS_RUN_ID=$(gh api /repos/${{ github.repository }}/actions/artifacts --jq ".artifacts[] | select(.name == \"main-branch-stats\") | .workflow_run.id")
echo "run-id=${MAIN_STATS_RUN_ID}" >> $GITHUB_OUTPUT
- name: Install dependencies
run: npm ci
- name: Build project to generate PR stats
run: npm run build -- --profile --json pr-stats.json
- name: Download main branch stats artifact
uses: actions/download-artifact@v4
with:
name: main-branch-stats
path: main-branch-stats
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ steps.main-stats-info.outputs.run-id }}
- name: Generate stats report and comment on PR
uses: actions/github-script@v6
with:
script: |
const script = require('.github/scripts/compareStats.js')
await script({github, context, core}, "main-branch-stats/stats.json", "pr-stats.json")