fix(templates): stabilize registry sync linting #2928
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: ReleaseOrVersionPR | |
| on: | |
| push: | |
| branches: [main] | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| release: | |
| name: Release and changelog | |
| runs-on: ubuntu-latest | |
| if: ${{ github.repository == 'udecode/plate' && github.ref == 'refs/heads/main' && !contains(github.event.head_commit.message, '[skip release]') }} | |
| outputs: | |
| published: ${{ steps.changesets.outputs.published }} | |
| publishedPackages: ${{ steps.changesets.outputs.publishedPackages }} | |
| steps: | |
| - name: π₯ Checkout Repo | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: β»οΈ Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| - name: π¦ Monorepo install | |
| uses: ./.github/actions/pnpm-install | |
| with: | |
| link-workspace-packages: 'true' | |
| - name: π¦ Create Release Pull Request or Publish | |
| id: changesets | |
| uses: changesets/action@v1 | |
| with: | |
| cwd: ${{ github.workspace }} | |
| title: '[Release] Version packages' | |
| publish: pnpm release | |
| env: | |
| HOME: ${{ github.workspace }} | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| sync-release-artifacts: | |
| name: Sync registry and templates after publish | |
| runs-on: ubuntu-latest | |
| needs: release | |
| if: ${{ needs.release.result == 'success' && needs.release.outputs.published == 'true' }} | |
| steps: | |
| - name: π₯ Checkout Repo | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.API_TOKEN_GITHUB || secrets.GITHUB_TOKEN }} | |
| - uses: oven-sh/setup-bun@v2 | |
| name: Install bun | |
| with: | |
| bun-version: 1.3.9 | |
| - name: β»οΈ Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| - name: π¦ Monorepo install | |
| uses: ./.github/actions/pnpm-install | |
| with: | |
| link-workspace-packages: 'true' | |
| - name: π§ Configure git | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| - name: π Build production registry | |
| run: pnpm --filter www build:registry && pnpm --filter www build:tw | |
| - name: β¬οΈ Push registry updates | |
| id: push-registry | |
| run: | | |
| git add . | |
| if git diff --cached --quiet; then | |
| echo "changed=false" >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| git commit -m "chore: update registry after release [skip release]" | |
| git push origin HEAD:main | |
| echo "changed=true" >> "$GITHUB_OUTPUT" | |
| - name: β³ Wait for npm propagation | |
| env: | |
| PUBLISHED_PACKAGES_JSON: ${{ needs.release.outputs.publishedPackages }} | |
| run: node tooling/scripts/await-npm-publish.mjs | |
| - name: π Build local dev registry | |
| run: pnpm --filter www rd | |
| - name: π Update templates | |
| id: update-templates | |
| continue-on-error: true | |
| env: | |
| TEMPLATE_SKIP_VERIFY: 'true' | |
| run: pnpm templates:update --local | |
| - name: π Detect template changes | |
| id: template-changes | |
| run: | | |
| if [[ -n "$(git status --porcelain --untracked-files=all -- templates)" ]]; then | |
| echo "changed=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "changed=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: β Run template CI | |
| id: template-ci | |
| if: ${{ steps.template-changes.outputs.changed == 'true' && steps.update-templates.outcome == 'success' }} | |
| continue-on-error: true | |
| run: | | |
| cd templates/plate-template | |
| bun install --no-frozen-lockfile | |
| bun lint | |
| bun run build | |
| cd ../plate-playground-template | |
| bun install --no-frozen-lockfile | |
| bun lint | |
| bun run build | |
| - name: β¬οΈ Push template updates | |
| if: ${{ steps.template-changes.outputs.changed == 'true' && steps.update-templates.outcome == 'success' && steps.template-ci.outcome == 'success' }} | |
| run: | | |
| git add templates | |
| git commit -m "chore: sync templates after release [skip release]" | |
| git push origin HEAD:main | |
| - name: β»οΈ Create template fix PR | |
| if: ${{ steps.template-changes.outputs.changed == 'true' && (steps.update-templates.outcome != 'success' || steps.template-ci.outcome != 'success') }} | |
| uses: peter-evans/create-pull-request@v7 | |
| with: | |
| token: ${{ secrets.API_TOKEN_GITHUB || secrets.GITHUB_TOKEN }} | |
| title: 'Fix template sync after release' | |
| body: | | |
| Template sync after release produced changes but did not pass automation. | |
| - `pnpm templates:update --local`: `${{ steps.update-templates.outcome }}` | |
| - template CI: `${{ steps.template-ci.outcome || 'skipped' }}` | |
| commit-message: 'chore: fix template sync after release [skip release]' | |
| committer: GitHub <noreply@github.com> | |
| branch: templates/release-sync-failure | |
| delete-branch: true | |
| add-paths: | | |
| templates/**/* | |
| - name: β Fail on template sync errors | |
| if: ${{ steps.update-templates.outcome != 'success' || (steps.template-changes.outputs.changed == 'true' && steps.template-ci.outcome != 'success') }} | |
| run: | | |
| echo "Template sync automation failed." | |
| exit 1 |