chore(docs): Update documentation #13
Workflow file for this run
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: Deploy PR Preview to Cloudflare Pages | |
| on: | |
| pull_request: | |
| branches: | |
| - main | |
| paths-ignore: | |
| - '.github/**' | |
| - 'docs/**' | |
| - 'playground/**' | |
| - 'src/lib/**' | |
| - '.gitignore' | |
| - '.npmrc' | |
| - '.prettierignore' | |
| - '.prettierrc' | |
| - 'add-component-help.ps1' | |
| - 'AGENTS.md' | |
| - 'eslint.config.js' | |
| - 'LICENSE' | |
| - 'package.json' | |
| - 'package-lock.json' | |
| - 'README.md' | |
| - 'tsconfig.json' | |
| jobs: | |
| preview: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '24' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build | |
| run: npm run build | |
| - name: Deploy Preview to Cloudflare Pages | |
| uses: cloudflare/wrangler-action@v3 | |
| with: | |
| apiToken: ${{ secrets.CF_API_TOKEN }} | |
| accountId: ${{ secrets.CF_ACC_ID }} | |
| command: pages deploy build --project-name=svelte-router --branch=preview-${{ github.event.number }} --commit-message="PR #${{ github.event.number }}: ${{ github.event.pull_request.title }}" | |
| - name: Update PR with Preview URL | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const prNumber = context.issue.number; | |
| const branchName = `preview-${prNumber}`; | |
| const previewUrl = `https://${branchName}.svelte-router.pages.dev`; | |
| const commentTitle = '🚀 **Preview deployment ready!**'; | |
| // Look for existing preview comment | |
| const comments = await github.rest.issues.listComments({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: prNumber | |
| }); | |
| const botComment = comments.data.find(comment => | |
| comment.user.type === 'Bot' && | |
| comment.body.includes(commentTitle) | |
| ); | |
| // Extract deployment count from existing comment or start at 1 | |
| let deploymentCount = 1; | |
| if (botComment) { | |
| const match = botComment.body.match(/(\d+) deployment/); | |
| deploymentCount = match ? parseInt(match[1]) + 1 : 2; | |
| } | |
| const commentBody = [ | |
| `${commentTitle} (${deploymentCount} ${deploymentCount === 1 ? 'deployment' : 'deployments'})`, | |
| '', | |
| `📍 **Preview URL:** ${previewUrl}`, | |
| '', | |
| '*This preview updates automatically when you push new commits to this PR.*' | |
| ].join('\n'); | |
| if (botComment) { | |
| // Update existing comment | |
| await github.rest.issues.updateComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| comment_id: botComment.id, | |
| body: commentBody | |
| }); | |
| } else { | |
| // Create new comment | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: prNumber, | |
| body: commentBody | |
| }); | |
| } |