@@ -36,13 +36,42 @@ jobs:
3636 - name : Install Brotli
3737 if : github.event_name == 'pull_request'
3838 run : sudo apt-get update && sudo apt-get install brotli
39- - name : Check Package Size
39+ - name : Get package size
4040 if : github.event_name == 'pull_request' && matrix.version == '21'
4141 env :
4242 PR_NUMBER : ${{ github.event.number }}
4343 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
4444 run : |
4545 brotli packages/sdk/browser/dist/index.js
46- export PR_SIZE=$(stat -c %s packages/sdk/browser/dist/index.js.br)
47- gh pr comment --edit-last $PR_NUMBER -b "@launchdarkly/js-client-sdk: $PR_SIZE" || gh pr comment $PR_NUMBER -b "@launchdarkly/js-client-sdk: $PR_SIZE"
48- [ $PR_SIZE -le 25000 ] || exit 1
46+ export PACK_SIZE=$(stat -c %s packages/sdk/browser/dist/index.js.br)
47+ echo "PACK_SIZE=$PACK_SIZE" >> $GITHUB_ENV
48+
49+ - name : Find Size Comment
50+ if : github.event_name == 'pull_request' && matrix.version == '21'
51+ uses : peter-evans/find-comment@v3
52+ id : fc
53+ with :
54+ comment-author : ' github-actions[bot]'
55+ body-includes : ' @launchdarkly/js-client-sdk size report'
56+
57+ - name : Create comment
58+ if : steps.fc.outputs.comment-id == '' && github.event_name == 'pull_request' && matrix.version == '21'
59+ uses : peter-evans/create-or-update-comment@v4
60+ with :
61+ body : |
62+ @launchdarkly/js-client-sdk size report
63+ Size: ${{ env.PACK_SIZE }} bytes
64+
65+ - name : Update comment
66+ if : steps.fc.outputs.comment-id != '' && github.event_name == 'pull_request' && matrix.version == '21'
67+ uses : peter-evans/create-or-update-comment@v4
68+ with :
69+ comment-id : ${{ steps.fc.outputs.comment-id }}
70+ body : |
71+ @launchdarkly/js-client-sdk size report
72+ Size: ${{ env.PACK_SIZE }} bytes
73+
74+ - name : Check package size limit
75+ if : github.event_name == 'pull_request' && matrix.version == '21'
76+ run : |
77+ [ $PACK_SIZE -le 25000 ] || exit 1
0 commit comments