name: CI on: push: branches: - main - next pull_request: types: - opened - synchronize - reopened workflow_dispatch: permissions: contents: write # Add concurrency to cancel redundant runs concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: ci: name: CI runs-on: ubuntu-latest # PRs into next skip without SKIP_NEXT_CI, which forked PRs never see. if: >- github.base_ref != 'next' && (vars.SKIP_NEXT_CI != 'true' || github.event_name == 'workflow_dispatch' || github.ref_name != 'next') && ( github.event_name != 'push' || ( github.event.head_commit.message != 'Version Packages' && !contains(github.event.head_commit.message, '[Release] Version packages') && !contains(github.event.head_commit.message, '[skip ci]') ) ) env: GENERATED_RELEASE_PR: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && startsWith(github.event.pull_request.head.ref, 'changeset-release/') }} steps: - uses: actions/checkout@v4 if: ${{ env.GENERATED_RELEASE_PR != 'true' }} with: fetch-depth: 0 token: ${{ secrets.API_TOKEN_GITHUB || secrets.GITHUB_TOKEN }} - name: ✅ Skip generated release PR if: ${{ env.GENERATED_RELEASE_PR == 'true' }} run: echo "Generated Changesets release PR; release workflow validates package output." - name: Setup Node.js if: ${{ env.GENERATED_RELEASE_PR != 'true' }} uses: actions/setup-node@v4 with: node-version: 22 - name: Install bun if: ${{ env.GENERATED_RELEASE_PR != 'true' }} uses: oven-sh/setup-bun@v2 with: bun-version: 1.4.4 - name: 📥 Monorepo install if: ${{ env.GENERATED_RELEASE_PR != 'true' }} uses: ./.github/actions/pnpm-install - name: ♻️ Restore packages cache if: ${{ env.GENERATED_RELEASE_PR != 'true' }} uses: actions/cache@v4 with: path: | ${{ github.workspace }}/.cache ${{ github.workspace }}/.turbo ${{ github.workspace }}/**/tsconfig.tsbuildinfo key: packages-cache-v2-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}-${{ github.sha }} restore-keys: | packages-cache-v2-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}- # A push commits barrel drift for the author; anywhere else the barrels # step in pnpm check fails on it. - name: 🧱 Generate barrels if: ${{ env.GENERATED_RELEASE_PR != 'true' && github.event_name == 'push' }} run: pnpm brl - name: 🔍 Detect barrel changes if: ${{ env.GENERATED_RELEASE_PR != 'true' && github.event_name == 'push' }} id: barrel-changes run: | if [[ -n "$(git status --porcelain --untracked-files=all -- packages)" ]]; then git status --short -- packages echo "changed=true" >> "$GITHUB_OUTPUT" else echo "changed=false" >> "$GITHUB_OUTPUT" fi - name: 🎭 Install Chromium for package tests if: ${{ env.GENERATED_RELEASE_PR != 'true' }} run: pnpm plite:browser:install chromium - name: ✅ Check if: ${{ env.GENERATED_RELEASE_PR != 'true' }} env: PLATE_BASELINE_BASE: ${{ github.event.pull_request.base.sha || github.event.before }} run: pnpm check --build - name: 🔧 Configure git if: ${{ env.GENERATED_RELEASE_PR != 'true' && github.event_name == 'push' && steps.barrel-changes.outputs.changed == 'true' && github.repository == 'udecode/plate' }} run: | git config user.name "github-actions[bot]" git config user.email "41898282+github-actions[bot]@users.noreply.github.com" - name: ⬆️ Push barrel updates if: ${{ env.GENERATED_RELEASE_PR != 'true' && github.event_name == 'push' && steps.barrel-changes.outputs.changed == 'true' && github.repository == 'udecode/plate' }} run: | git add packages git commit -m "chore: sync barrels [skip ci] [skip release]" git push origin HEAD:${{ github.ref_name }} # notify-failure: # name: Discord Notification # runs-on: ubuntu-latest # needs: [ci] # if: ${{ github.event_name == 'push' && failure() }} # steps: # - name: Send Discord Notification # uses: nobrayner/discord-webhook@v1 # with: # github-token: ${{ secrets.X_GITHUB_READ_ACTIONS_TOKEN }} # discord-webhook: ${{ secrets.DISCORD_CI_WEBHOOK }} # description: ${{ github.event.number && format('https://github.com/udecode/plate/pull/{0}', github.event.number) || 'Push' }}