๐Ÿ“ฆ payloadcms / payload

๐Ÿ“„ main.yml ยท 738 lines
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738name: ci

on:
  pull_request:
    types: [opened, reopened, synchronize]

  push:
    branches: [main]

concurrency:
  # <workflow_name>-<branch_name>-<true || commit_sha if branch is protected>
  group: ${{ github.workflow }}-${{ github.ref }}-${{ github.ref_protected && github.sha || ''}}
  cancel-in-progress: true

env:
  DO_NOT_TRACK: 1 # Disable Turbopack telemetry
  NEXT_TELEMETRY_DISABLED: 1 # Disable Next telemetry

jobs:
  changes:
    runs-on: ubuntu-24.04
    permissions:
      pull-requests: read
    outputs:
      needs_build: ${{ steps.filter.outputs.needs_build }}
      needs_tests: ${{ steps.filter.outputs.needs_tests }}
      templates: ${{ steps.filter.outputs.templates }}
    steps:
      # https://github.com/actions/virtual-environments/issues/1187
      - name: tune linux network
        run: sudo ethtool -K eth0 tx off rx off

      - uses: actions/checkout@v5
      - uses: dorny/paths-filter@v3
        id: filter
        with:
          filters: |
            needs_build:
              - '.github/workflows/main.yml'
              - 'packages/**'
              - 'test/**'
              - 'pnpm-lock.yaml'
              - 'package.json'
              - 'templates/**'
            needs_tests:
              - '.github/workflows/main.yml'
              - 'packages/**'
              - 'test/**'
              - 'pnpm-lock.yaml'
              - 'package.json'
            templates:
              - 'templates/**'
      - name: Log filter results
        run: |
          echo "needs_build: ${{ steps.filter.outputs.needs_build }}"
          echo "needs_tests: ${{ steps.filter.outputs.needs_tests }}"
          echo "templates: ${{ steps.filter.outputs.templates }}"

  lint:
    runs-on: ubuntu-24.04
    steps:
      - uses: actions/checkout@v5
        with:
          fetch-depth: 0

      - name: Node setup
        uses: ./.github/actions/setup

      - name: Lint TypeScript/JavaScript
        run: pnpm lint -- --quiet

      - name: Lint SCSS
        run: pnpm run lint:scss

  build:
    needs: changes
    if: needs.changes.outputs.needs_build == 'true'
    runs-on: ubuntu-24.04

    steps:
      - uses: actions/checkout@v5

      - name: Node setup
        uses: ./.github/actions/setup

      - run: pnpm run build:all
        env:
          DO_NOT_TRACK: 1 # Disable Turbopack telemetry

      - name: Cache build
        uses: actions/cache@v4
        with:
          path: ./*
          key: ${{ github.sha }}

  tests-unit:
    runs-on: ubuntu-24.04
    needs: [changes, build]
    if: needs.changes.outputs.needs_tests == 'true'
    steps:
      - uses: actions/checkout@v5

      - name: Node setup
        uses: ./.github/actions/setup
        with:
          pnpm-run-install: false
          pnpm-restore-cache: false # Full build is restored below

      - name: Restore build
        uses: actions/cache@v4
        with:
          path: ./*
          key: ${{ github.sha }}

      - name: Unit Tests
        run: pnpm test:unit
        env:
          NODE_OPTIONS: --max-old-space-size=8096

  tests-types:
    runs-on: ubuntu-24.04
    needs: [changes, build]
    if: needs.changes.outputs.needs_tests == 'true'
    steps:
      - uses: actions/checkout@v5

      - name: Node setup
        uses: ./.github/actions/setup
        with:
          pnpm-run-install: false
          pnpm-restore-cache: false # Full build is restored below

      - name: Restore build
        uses: actions/cache@v4
        with:
          path: ./*
          key: ${{ github.sha }}

      - name: Types Tests
        run: pnpm test:types --target '>=5.7'
        env:
          NODE_OPTIONS: --max-old-space-size=8096

  tests-int:
    runs-on: ubuntu-24.04
    needs: [changes, build]
    if: needs.changes.outputs.needs_tests == 'true'
    name: int-${{ matrix.database }}
    timeout-minutes: 45
    strategy:
      fail-fast: false
      matrix:
        database:
          - mongodb
          - mongodb-atlas
          - documentdb
          - cosmosdb
          - firestore
          - postgres
          - postgres-custom-schema
          - postgres-uuid
          - supabase
          - sqlite
          - sqlite-uuid

    env:
      AWS_ENDPOINT_URL: http://127.0.0.1:4566
      AWS_ACCESS_KEY_ID: localstack
      AWS_SECRET_ACCESS_KEY: localstack
      AWS_REGION: us-east-1

    services:
      redis:
        image: redis:latest
        ports:
          - 6379:6379

        options: --health-cmd "redis-cli ping" --health-timeout 30s --health-retries 3

    steps:
      - uses: actions/checkout@v5

      - name: Node setup
        uses: ./.github/actions/setup
        with:
          pnpm-run-install: false
          pnpm-restore-cache: false # Full build is restored below

      - name: Restore build
        uses: actions/cache@v4
        with:
          path: ./*
          key: ${{ github.sha }}

      - name: Start LocalStack
        run: pnpm docker:start

      - name: Configure Redis
        run: |
          echo "REDIS_URL=redis://127.0.0.1:6379" >> $GITHUB_ENV

      - name: Start database
        id: db
        uses: ./.github/actions/start-database
        with:
          database: ${{ matrix.database }}

      - name: Integration Tests
        run: pnpm test:int
        env:
          NODE_OPTIONS: --max-old-space-size=8096
          PAYLOAD_DATABASE: ${{ matrix.database }}
          POSTGRES_URL: ${{ steps.db.outputs.POSTGRES_URL }}
          MONGODB_URL: ${{ steps.db.outputs.MONGODB_URL }}
          MONGODB_ATLAS_URL: ${{ steps.db.outputs.MONGODB_ATLAS_URL }}

  tests-e2e:
    runs-on: ubuntu-24.04
    needs: [changes, build]
    if: needs.changes.outputs.needs_tests == 'true'
    name: e2e-${{ matrix.suite }}
    timeout-minutes: 45
    strategy:
      fail-fast: false
      matrix:
        # find test -type f -name 'e2e.spec.ts' | sort | xargs dirname | xargs -I {} basename {}
        suite:
          - _community
          - a11y
          - access-control
          - admin__e2e__general
          - admin__e2e__list-view
          - admin__e2e__document-view
          - admin-bar
          - admin-root
          - auth
          - auth-basic
          - bulk-edit
          - dashboard
          - joins
          - field-error-states
          - field-paths
          - fields-relationship
          - fields__collections__Array
          - fields__collections__Blocks
          - fields__collections__Blocks#config.blockreferences.ts
          - fields__collections__Checkbox
          - fields__collections__Collapsible
          - fields__collections__ConditionalLogic
          - fields__collections__CustomID
          - fields__collections__Date
          - fields__collections__Email
          - fields__collections__Indexed
          - fields__collections__JSON
          - fields__collections__Number
          - fields__collections__Point
          - fields__collections__Radio
          - fields__collections__Relationship
          - fields__collections__Row
          - fields__collections__Select
          - fields__collections__Tabs
          - fields__collections__Tabs2
          - fields__collections__Text
          - fields__collections__UI
          - fields__collections__Upload
          - fields__collections__UploadPoly
          - fields__collections__UploadMultiPoly
          - group-by
          - folders
          - hooks
          - lexical__collections___LexicalFullyFeatured
          - lexical__collections___LexicalFullyFeatured__db
          - lexical__collections__LexicalHeadingFeature
          - lexical__collections__LexicalJSXConverter
          - lexical__collections__LexicalLinkFeature
          - lexical__collections__OnDemandForm
          - lexical__collections__Lexical__e2e__main
          - lexical__collections__Lexical__e2e__blocks
          - lexical__collections__Lexical__e2e__blocks#config.blockreferences.ts
          - lexical__collections__RichText
          - query-presets
          - form-state
          - live-preview
          - localization
          - locked-documents
          - i18n
          - plugin-cloud-storage
          - plugin-form-builder
          - plugin-import-export
          - plugin-multi-tenant
          - plugin-nested-docs
          - plugin-redirects
          - plugin-seo
          - queues
          - sort
          - server-url
          - trash
          - versions
          - uploads
    env:
      SUITE_NAME: ${{ matrix.suite }}
    steps:
      - uses: actions/checkout@v5

      - name: Node setup
        uses: ./.github/actions/setup
        with:
          pnpm-run-install: false
          pnpm-restore-cache: false # Full build is restored below

      - name: Restore build
        uses: actions/cache@v4
        with:
          path: ./*
          key: ${{ github.sha }}

      - name: Start LocalStack
        run: pnpm docker:start
        if: matrix.suite == 'plugin-cloud-storage'

      - name: Start database
        id: db
        uses: ./.github/actions/start-database
        with:
          database: mongodb

      - name: Store Playwright's Version
        run: |
          # Extract the version number using a more targeted regex pattern with awk
          PLAYWRIGHT_VERSION=$(pnpm ls @playwright/test --depth=0 | awk '/@playwright\/test/ {print $2}')
          echo "Playwright's Version: $PLAYWRIGHT_VERSION"
          echo "PLAYWRIGHT_VERSION=$PLAYWRIGHT_VERSION" >> $GITHUB_ENV

      - name: Cache Playwright Browsers for Playwright's Version
        id: cache-playwright-browsers
        uses: actions/cache@v4
        with:
          path: ~/.cache/ms-playwright
          key: playwright-browsers-${{ env.PLAYWRIGHT_VERSION }}

      - name: Setup Playwright - Browsers and Dependencies
        if: steps.cache-playwright-browsers.outputs.cache-hit != 'true'
        run: pnpm exec playwright install --with-deps chromium --no-shell

      - name: Setup Playwright - Dependencies-only
        if: steps.cache-playwright-browsers.outputs.cache-hit == 'true'
        run: pnpm exec playwright install-deps chromium

      - name: E2E Tests
        run: PLAYWRIGHT_JSON_OUTPUT_NAME=results_${{ matrix.suite }}.json pnpm test:e2e:prod:ci:noturbo ${{ matrix.suite }}
        env:
          PLAYWRIGHT_JSON_OUTPUT_NAME: results_${{ matrix.suite }}.json
          NEXT_TELEMETRY_DISABLED: 1

      - uses: actions/upload-artifact@v4
        if: always()
        with:
          name: test-results-${{ matrix.suite }}
          path: test/test-results/
          if-no-files-found: ignore
          retention-days: 1

      # Disabled until this is fixed: https://github.com/daun/playwright-report-summary/issues/156
      # - uses: daun/playwright-report-summary@v3
      #   with:
      #     report-file: results_${{ matrix.suite }}.json
      #     report-tag: ${{ matrix.suite }}
      #     job-summary: true

  # This is unused, keeping it here for reference and possibly enabling in the future
  tests-e2e-turbo:
    runs-on: ubuntu-24.04
    needs: [changes, build]
    if: >-
      needs.changes.outputs.needs_tests == 'true' &&
      (
        contains(github.event.pull_request.labels.*.name, 'run-e2e-turbo') ||
        github.event.label.name == 'run-e2e-turbo'
      )
    name: e2e-turbo-${{ matrix.suite }}
    strategy:
      fail-fast: false
      matrix:
        # find test -type f -name 'e2e.spec.ts' | sort | xargs dirname | xargs -I {} basename {}
        suite:
          - _community
          - access-control
          - admin__e2e__general
          - admin__e2e__list-view
          - admin__e2e__document-view
          - admin-bar
          - admin-root
          - auth
          - auth-basic
          - bulk-edit
          - dashboard
          - joins
          - field-error-states
          - fields-relationship
          - fields__collections__Array
          - fields__collections__Blocks
          - fields__collections__Blocks#config.blockreferences.ts
          - fields__collections__Checkbox
          - fields__collections__Collapsible
          - fields__collections__ConditionalLogic
          - fields__collections__CustomID
          - fields__collections__Date
          - fields__collections__Email
          - fields__collections__Indexed
          - fields__collections__JSON
          - fields__collections__Number
          - fields__collections__Point
          - fields__collections__Radio
          - fields__collections__Relationship
          - fields__collections__Row
          - fields__collections__Select
          - fields__collections__Tabs
          - fields__collections__Tabs2
          - fields__collections__Text
          - fields__collections__UI
          - fields__collections__Upload
          - group-by
          - folders
          - hooks
          - lexical__collections___LexicalFullyFeatured
          - lexical__collections___LexicalFullyFeatured__db
          - lexical__collections__LexicalHeadingFeature
          - lexical__collections__LexicalJSXConverter
          - lexical__collections__LexicalLinkFeature
          - lexical__collections__OnDemandForm
          - lexical__collections__Lexical__e2e__main
          - lexical__collections__Lexical__e2e__blocks
          - lexical__collections__Lexical__e2e__blocks#config.blockreferences.ts
          - lexical__collections__RichText
          - query-presets
          - form-state
          - live-preview
          - localization
          - locked-documents
          - i18n
          - plugin-cloud-storage
          - plugin-form-builder
          - plugin-import-export
          - plugin-multi-tenant
          - plugin-nested-docs
          - plugin-seo
          - queues
          - sort
          - trash
          - versions
          - uploads
    env:
      SUITE_NAME: ${{ matrix.suite }}
    steps:
      - uses: actions/checkout@v5

      - name: Node setup
        uses: ./.github/actions/setup
        with:
          pnpm-run-install: false
          pnpm-restore-cache: false # Full build is restored below

      - name: Restore build
        uses: actions/cache@v4
        with:
          path: ./*
          key: ${{ github.sha }}

      - name: Start LocalStack
        run: pnpm docker:start
        if: matrix.suite == 'plugin-cloud-storage'

      - name: Store Playwright's Version
        run: |
          # Extract the version number using a more targeted regex pattern with awk
          PLAYWRIGHT_VERSION=$(pnpm ls @playwright/test --depth=0 | awk '/@playwright\/test/ {print $2}')
          echo "Playwright's Version: $PLAYWRIGHT_VERSION"
          echo "PLAYWRIGHT_VERSION=$PLAYWRIGHT_VERSION" >> $GITHUB_ENV

      - name: Cache Playwright Browsers for Playwright's Version
        id: cache-playwright-browsers
        uses: actions/cache@v4
        with:
          path: ~/.cache/ms-playwright
          key: playwright-browsers-${{ env.PLAYWRIGHT_VERSION }}

      - name: Setup Playwright - Browsers and Dependencies
        if: steps.cache-playwright-browsers.outputs.cache-hit != 'true'
        run: pnpm exec playwright install --with-deps chromium

      - name: Setup Playwright - Dependencies-only
        if: steps.cache-playwright-browsers.outputs.cache-hit == 'true'
        run: pnpm exec playwright install-deps chromium

      - name: E2E Tests
        run: PLAYWRIGHT_JSON_OUTPUT_NAME=results_${{ matrix.suite }}.json pnpm test:e2e:prod:ci ${{ matrix.suite }}
        env:
          PLAYWRIGHT_JSON_OUTPUT_NAME: results_${{ matrix.suite }}.json
          NEXT_TELEMETRY_DISABLED: 1

      - uses: actions/upload-artifact@v4
        if: always()
        with:
          name: test-results-turbo${{ matrix.suite }}
          path: test/test-results/
          if-no-files-found: ignore
          retention-days: 1

      # Disabled until this is fixed: https://github.com/daun/playwright-report-summary/issues/156
      # - uses: daun/playwright-report-summary@v3
      #   with:
      #     report-file: results_${{ matrix.suite }}.json
      #     report-tag: ${{ matrix.suite }}
      #     job-summary: true

  # Build listed templates with packed local packages and then runs their int and e2e tests
  build-and-test-templates:
    runs-on: ubuntu-24.04
    needs: [changes, build]
    if: needs.changes.outputs.needs_build == 'true'
    name: build-template-${{ matrix.template }}-${{ matrix.database }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - template: blank
            database: mongodb

          - template: website
            database: mongodb

          - template: with-vercel-mongodb
            database: mongodb

          # Postgres
          - template: with-postgres
            database: postgres

          - template: with-vercel-postgres
            database: postgres

          - template: plugin

          # Re-enable once PG conncection is figured out
          # - template: with-vercel-website
          #   database: postgres

    env:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres
      POSTGRES_DB: payloadtests
      MONGODB_VERSION: 6.0

    steps:
      - uses: actions/checkout@v5

      - name: Node setup
        uses: ./.github/actions/setup
        with:
          pnpm-run-install: false
          pnpm-restore-cache: false # Full build is restored below

      - name: Restore build
        uses: actions/cache@v4
        with:
          path: ./*
          key: ${{ github.sha }}

      - name: Start PostgreSQL
        uses: CasperWA/postgresql-action@v1.2
        with:
          postgresql version: '14' # See https://hub.docker.com/_/postgres for available versions
          postgresql db: ${{ env.POSTGRES_DB }}
          postgresql user: ${{ env.POSTGRES_USER }}
          postgresql password: ${{ env.POSTGRES_PASSWORD }}
        if: matrix.database == 'postgres'

      - name: Wait for PostgreSQL
        run: sleep 30
        if: matrix.database == 'postgres'

      - name: Configure PostgreSQL
        run: |
          psql "postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@localhost:5432/$POSTGRES_DB" -c "CREATE ROLE runner SUPERUSER LOGIN;"
          psql "postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@localhost:5432/$POSTGRES_DB" -c "SELECT version();"
          echo "POSTGRES_URL=postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@localhost:5432/$POSTGRES_DB" >> $GITHUB_ENV
        if: matrix.database == 'postgres'

      # Avoid dockerhub rate-limiting
      - name: Cache Docker images
        # Use AndreKurait/docker-cache@0.6.0 instead of ScribeMD/docker-cache@0.5.0 to fix the following issue: https://github.com/ScribeMD/docker-cache/issues/837 ("Warning: Failed to restore: Cache service responded with 400")
        uses: AndreKurait/docker-cache@0.6.0
        with:
          key: docker-${{ runner.os }}-mongo-${{ env.MONGODB_VERSION }}

      - name: Start MongoDB
        uses: supercharge/mongodb-github-action@1.12.0
        with:
          mongodb-version: 6.0
        if: matrix.database == 'mongodb'

      - name: Build Template
        run: |
          pnpm run script:pack --dest templates/${{ matrix.template }}
          pnpm run script:build-template-with-local-pkgs ${{ matrix.template }} $POSTGRES_URL
        env:
          NODE_OPTIONS: --max-old-space-size=8096

      - name: Store Playwright's Version
        run: |
          # Extract the version number using a more targeted regex pattern with awk
          PLAYWRIGHT_VERSION=$(pnpm ls @playwright/test --depth=0 | awk '/@playwright\/test/ {print $2}')
          echo "Playwright's Version: $PLAYWRIGHT_VERSION"
          echo "PLAYWRIGHT_VERSION=$PLAYWRIGHT_VERSION" >> $GITHUB_ENV

      - name: Cache Playwright Browsers for Playwright's Version
        id: cache-playwright-browsers
        uses: actions/cache@v4
        with:
          path: ~/.cache/ms-playwright
          key: playwright-browsers-${{ env.PLAYWRIGHT_VERSION }}

      - name: Setup Playwright - Browsers and Dependencies
        if: steps.cache-playwright-browsers.outputs.cache-hit != 'true'
        run: pnpm exec playwright install --with-deps chromium

      - name: Setup Playwright - Dependencies-only
        if: steps.cache-playwright-browsers.outputs.cache-hit == 'true'
        run: pnpm exec playwright install-deps chromium

      - name: Runs Template Int Tests
        run: pnpm --filter ${{ matrix.template }} run test:int
        env:
          NODE_OPTIONS: --max-old-space-size=8096
          PAYLOAD_DATABASE: ${{ matrix.database }}
          POSTGRES_URL: ${{ env.POSTGRES_URL }}
          MONGODB_URL: mongodb://localhost:27017/payloadtests

      - name: Runs Template E2E Tests
        run: PLAYWRIGHT_JSON_OUTPUT_NAME=results_${{ matrix.template }}.json pnpm --filter ${{ matrix.template }} test:e2e
        env:
          NODE_OPTIONS: --max-old-space-size=8096
          PAYLOAD_DATABASE: ${{ matrix.database }}
          POSTGRES_URL: ${{ env.POSTGRES_URL }}
          MONGODB_URL: mongodb://localhost:27017/payloadtests
          NEXT_TELEMETRY_DISABLED: 1

  tests-type-generation:
    runs-on: ubuntu-24.04
    needs: [changes, build]
    if: needs.changes.outputs.needs_tests == 'true'
    steps:
      - uses: actions/checkout@v5

      - name: Node setup
        uses: ./.github/actions/setup
        with:
          pnpm-run-install: false
          pnpm-restore-cache: false # Full build is restored below

      - name: Restore build
        uses: actions/cache@v4
        with:
          path: ./*
          key: ${{ github.sha }}

      - name: Generate Payload Types
        run: pnpm dev:generate-types fields

      - name: Generate GraphQL schema file
        run: pnpm dev:generate-graphql-schema graphql-schema-gen

  all-green:
    name: All Green
    if: always()
    runs-on: ubuntu-24.04
    needs:
      [
        lint,
        build,
        build-and-test-templates,
        tests-unit,
        tests-int,
        tests-e2e,
        tests-types,
        tests-type-generation,
      ]

    steps:
      - if: ${{ always() && (contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')) }}
        run: exit 1

  publish-canary:
    name: Publish Canary
    runs-on: ubuntu-24.04
    if: ${{ needs.all-green.result == 'success' && github.ref_name == 'main' }}
    needs:
      - all-green

    steps:
      # debug github.ref output
      - run: |
          echo github.ref: ${{ github.ref }}
          echo isV3: ${{ github.ref == 'refs/heads/main' }}
  analyze:
    runs-on: ubuntu-latest
    needs: [changes, build]
    timeout-minutes: 5
    permissions:
      contents: read # for checkout repository
      actions: read # for fetching base branch bundle stats
      pull-requests: write # for comments
    steps:
      - uses: actions/checkout@v5

      - name: Node setup
        uses: ./.github/actions/setup
        with:
          pnpm-run-install: false
          pnpm-restore-cache: false # Full build is restored below

      - name: Restore build
        uses: actions/cache@v4
        with:
          path: ./*
          key: ${{ github.sha }}

      - run: pnpm run build:bundle-for-analysis # Esbuild packages that haven't already been built in the build step for the purpose of analyzing bundle size
        env:
          DO_NOT_TRACK: 1 # Disable Turbopack telemetry

      - name: Analyze esbuild bundle size
        # Temporarily disable this for community PRs until this can be implemented in a separate workflow
        if: github.event.pull_request.head.repo.fork == false
        uses: exoego/esbuild-bundle-analyzer@v1
        with:
          metafiles: 'packages/payload/meta_index.json,packages/payload/meta_shared.json,packages/ui/meta_client.json,packages/ui/meta_shared.json,packages/next/meta_index.json,packages/richtext-lexical/meta_client.json'