chore(release): publish a new release version (#865) #38
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: Export Demo Templates | |
| on: | |
| push: | |
| branches: | |
| - master | |
| paths: | |
| - '.github/workflows/*' | |
| - 'apps/demo-react/**' | |
| - 'apps/demo-vue3/**' | |
| - 'scripts/export-demo-template.js' | |
| - 'package.json' | |
| - 'pnpm-lock.yaml' | |
| workflow_dispatch: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| export: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| app: | |
| - demo-react | |
| - demo-vue3 | |
| steps: | |
| - name: Checkout repo | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v5 | |
| with: | |
| version: 9.15.0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 22.13.0 | |
| registry-url: https://registry.npmjs.com | |
| cache: pnpm | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Export template | |
| run: | | |
| mkdir -p .demo-templates | |
| pnpm demo:export-template ${{ matrix.app }} .demo-templates/${{ matrix.app }} | |
| - name: Upload exported template | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: ${{ matrix.app }}-template | |
| path: .demo-templates/${{ matrix.app }} | |
| sync: | |
| runs-on: ubuntu-latest | |
| needs: export | |
| env: | |
| DEMO_TEMPLATES_BASE_DIR: ${{ vars.DEMO_TEMPLATES_BASE_DIR }} | |
| DEMO_TEMPLATES_BRANCH: ${{ vars.DEMO_TEMPLATES_BRANCH }} | |
| DEMO_TEMPLATES_REPO: ${{ vars.DEMO_TEMPLATES_REPO }} | |
| DEMO_TEMPLATES_TOKEN: ${{ secrets.DEMO_TEMPLATES_TOKEN }} | |
| steps: | |
| - name: Check sync configuration | |
| id: config | |
| run: | | |
| if [ -z "$DEMO_TEMPLATES_REPO" ] || [ -z "$DEMO_TEMPLATES_TOKEN" ]; then | |
| echo "sync_enabled=false" >> "$GITHUB_OUTPUT" | |
| echo "Template sync is not configured, skipping." | |
| exit 0 | |
| fi | |
| echo "sync_enabled=true" >> "$GITHUB_OUTPUT" | |
| - name: Download exported templates | |
| if: steps.config.outputs.sync_enabled == 'true' | |
| uses: actions/download-artifact@v8 | |
| with: | |
| path: .demo-templates | |
| - name: Checkout target repo | |
| if: steps.config.outputs.sync_enabled == 'true' | |
| run: | | |
| git clone "https://x-access-token:${DEMO_TEMPLATES_TOKEN}@github.com/${DEMO_TEMPLATES_REPO}.git" target-repo | |
| - name: Copy templates into target repo | |
| if: steps.config.outputs.sync_enabled == 'true' | |
| run: | | |
| TARGET_DIR="${DEMO_TEMPLATES_BASE_DIR:-.}" | |
| mkdir -p "target-repo/${TARGET_DIR}" | |
| rm -rf "target-repo/${TARGET_DIR}/demo-react" "target-repo/${TARGET_DIR}/demo-vue3" | |
| cp -R .demo-templates/demo-react-template "target-repo/${TARGET_DIR}/demo-react" | |
| cp -R .demo-templates/demo-vue3-template "target-repo/${TARGET_DIR}/demo-vue3" | |
| cat > "target-repo/${TARGET_DIR}/README.md" <<'EOF' | |
| # wangEditor Demo Templates | |
| Derived demo templates synced from `wangeditor-next/wangEditor-next`. | |
| Available templates: | |
| - `demo-react` | |
| - `demo-vue3` | |
| Open in StackBlitz: | |
| - React: https://stackblitz.com/fork/github/wangeditor-next/demo-templates/tree/main/demo-react?title=wangEditor%20React%20Demo&startScript=dev | |
| - Vue 3: https://stackblitz.com/fork/github/wangeditor-next/demo-templates/tree/main/demo-vue3?title=wangEditor%20Vue%203%20Demo&startScript=dev | |
| EOF | |
| - name: Commit and push template updates | |
| if: steps.config.outputs.sync_enabled == 'true' | |
| working-directory: target-repo | |
| run: | | |
| git config user.name "github-actions" | |
| git config user.email "github-actions@github.com" | |
| git add . | |
| if git diff --cached --quiet; then | |
| echo "No template changes to commit" | |
| exit 0 | |
| fi | |
| git commit -m "chore: sync wangEditor demo templates" | |
| git push origin "HEAD:${DEMO_TEMPLATES_BRANCH:-main}" |