Skip to content

Track package size over time. #27

Track package size over time.

Track package size over time. #27

Workflow file for this run

name: Chromatic Package Size
on:
pull_request:
branches: [main]
types: [opened, synchronize]
permissions:
contents: read
issues: write
pull-requests: write
jobs:
chromatic:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: lts/*
- run: corepack enable
- name: install
run: yarn install --immutable
- name: build
run: yarn build
- name: Get Package Size
id: package_size
run: |
export DIST_SIZE="$(du -k ./dist | cut -f1)"
echo "Package Size: $DIST_SIZE KB"
echo "size=$DIST_SIZE" >> "$GITHUB_OUTPUT"
- name: Get Previous SHAs
id: get_shas
run: |
export MERGE_BASE_SHA="$(git merge-base origin/main HEAD)"
export MAIN_HEAD_SHA="$(git rev-parse origin/main)"
echo " merge-base: $MERGE_BASE_SHA"
echo "origin/main: $MAIN_HEAD_SHA"
echo "merge_base=$MERGE_BASE_SHA" >> "$GITHUB_OUTPUT"
echo "main_head=$MAIN_HEAD_SHA" >> "$GITHUB_OUTPUT"
- name: Update Database
run: |
curl "https://busy-mollusk-22503.upstash.io/set/$GITHUB_SHA/${{ steps.package_size.outputs.size }}" -H "Authorization: Bearer ${{ secrets.UPSTASH_API_KEY }}"
- name: Get Previous Sizes
id: previous
run: |
export MERGE_BASE_RESULT="$(curl -s "https://busy-mollusk-22503.upstash.io/get/${{ steps.get_shas.outputs.merge_base }}" -H "Authorization: Bearer ${{ secrets.UPSTASH_API_KEY }}")"
export MAIN_HEAD_RESULT="$(curl -s "https://busy-mollusk-22503.upstash.io/get/${{ steps.get_shas.outputs.main_head }}" -H "Authorization: Bearer ${{ secrets.UPSTASH_API_KEY }}")"
echo " merge-base: $MERGE_BASE_RESULT"
echo "origin/main: $MAIN_HEAD_RESULT"
echo "merge_base=$MERGE_BASE_RESULT" >> "$GITHUB_OUTPUT"
echo "main_head=$MAIN_HEAD_RESULT" >> "$GITHUB_OUTPUT"
- uses: actions/github-script@v7
with:
script: |
const output = ["📦 Package Size: ${{ steps.package_size.outputs.size }} KB"];
console.log("Checking merge_base_json", `${{ steps.previous.outputs.merge_base }}`);
const merge_base_json = JSON.parse(`${{ steps.previous.outputs.merge_base }}`);
console.log(merge_base_json);