|
| 1 | +name: 'Auto-bump size-limit thresholds' |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + - cron: '0 9 * * 5' # Friday 09:00 UTC |
| 6 | + workflow_dispatch: |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + pull-requests: write |
| 11 | + issues: write |
| 12 | + |
| 13 | +env: |
| 14 | + CACHED_DEPENDENCY_PATHS: | |
| 15 | + ${{ github.workspace }}/node_modules |
| 16 | + ${{ github.workspace }}/packages/*/node_modules |
| 17 | + ${{ github.workspace }}/dev-packages/*/node_modules |
| 18 | + ~/.cache/mongodb-binaries/ |
| 19 | +
|
| 20 | +concurrency: |
| 21 | + group: bump-size-limits |
| 22 | + cancel-in-progress: false |
| 23 | + |
| 24 | +jobs: |
| 25 | + bump: |
| 26 | + name: Bump size-limit thresholds |
| 27 | + runs-on: ubuntu-24.04 |
| 28 | + timeout-minutes: 25 |
| 29 | + steps: |
| 30 | + - name: Generate GitHub App token |
| 31 | + id: app-token |
| 32 | + uses: actions/create-github-app-token@v2 |
| 33 | + with: |
| 34 | + app-id: ${{ vars.GITFLOW_APP_ID }} |
| 35 | + private-key: ${{ secrets.GITFLOW_APP_PRIVATE_KEY }} |
| 36 | + |
| 37 | + - name: Checkout develop |
| 38 | + uses: actions/checkout@v6 |
| 39 | + with: |
| 40 | + ref: develop |
| 41 | + token: ${{ steps.app-token.outputs.token }} |
| 42 | + |
| 43 | + - name: Set up Node |
| 44 | + uses: actions/setup-node@v6 |
| 45 | + with: |
| 46 | + node-version-file: 'package.json' |
| 47 | + |
| 48 | + - name: Install dependencies |
| 49 | + uses: ./.github/actions/install-dependencies |
| 50 | + |
| 51 | + - name: Build packages |
| 52 | + run: yarn build |
| 53 | + |
| 54 | + - name: Run bumper |
| 55 | + # Capture stdout AND exit code without failing the step on exit-2 (no-op). |
| 56 | + # The script writes .size-limit.js in place; create-pull-request handles |
| 57 | + # commit/branch/PR — if there's no diff, it skips opening a PR. |
| 58 | + run: | |
| 59 | + set +e |
| 60 | + node scripts/bump-size-limits.mjs > /tmp/bump-summary.md |
| 61 | + code=$? |
| 62 | + set -e |
| 63 | + if [ "$code" -ne 0 ] && [ "$code" -ne 2 ]; then |
| 64 | + echo "::error::bump script failed with exit code $code" |
| 65 | + cat /tmp/bump-summary.md || true |
| 66 | + exit "$code" |
| 67 | + fi |
| 68 | + cat /tmp/bump-summary.md |
| 69 | +
|
| 70 | + - name: Create or update PR |
| 71 | + uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0 |
| 72 | + with: |
| 73 | + token: ${{ steps.app-token.outputs.token }} |
| 74 | + commit-message: 'chore(size-limit): auto-bump weekly drift' |
| 75 | + title: 'chore(size-limit): weekly auto-bump' |
| 76 | + body-path: /tmp/bump-summary.md |
| 77 | + branch: bot/bump-size-limits |
| 78 | + base: develop |
| 79 | + labels: 'Dev: CI' |
| 80 | + add-paths: '.size-limit.js' |
| 81 | + delete-branch: true |
| 82 | + |
| 83 | + - name: Open or comment on failure issue |
| 84 | + if: failure() |
| 85 | + env: |
| 86 | + GH_TOKEN: ${{ steps.app-token.outputs.token }} |
| 87 | + RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} |
| 88 | + run: | |
| 89 | + title='Weekly size-limit auto-bump failure' |
| 90 | + existing=$(gh issue list --search "in:title \"$title\"" --state open --json number,title --jq ".[] | select(.title == \"$title\") | .number" | head -n1) |
| 91 | + if [ -n "$existing" ]; then |
| 92 | + gh issue comment "$existing" --body "Auto-bump workflow failed again: $RUN_URL" |
| 93 | + else |
| 94 | + body=$(cat <<EOF |
| 95 | + The weekly size-limit auto-bump workflow failed. |
| 96 | +
|
| 97 | + Run: $RUN_URL |
| 98 | +
|
| 99 | + This issue will be commented on for repeat failures. |
| 100 | + EOF |
| 101 | + ) |
| 102 | + gh issue create \ |
| 103 | + --title "$title" \ |
| 104 | + --body "$body" \ |
| 105 | + --label "Dev: CI" |
| 106 | + fi |
0 commit comments