Add: Performance and SEO optimizations #21
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: PR Preview Deploy | |
| on: | |
| pull_request: | |
| branches: [main] | |
| types: [opened, synchronize, reopened] | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| jobs: | |
| preview: | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: ./website | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: npm | |
| cache-dependency-path: ./website/package-lock.json | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build website | |
| run: npm run build | |
| env: | |
| NODE_OPTIONS: --max-old-space-size=4096 | |
| - name: Install Surge | |
| run: npm install -g surge | |
| - name: Deploy to Surge preview | |
| run: surge ./build cloudcaptain-pr-${{ github.event.pull_request.number }}.surge.sh --token ${{ secrets.SURGE_TOKEN }} | |
| - name: Comment preview URL on PR | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const prNumber = context.payload.pull_request.number; | |
| const previewUrl = `https://cloudcaptain-pr-${prNumber}.surge.sh`; | |
| const body = `## 🚀 Preview Deployment\n\n` + | |
| `Your changes have been deployed to a preview URL:\n\n` + | |
| `**[${previewUrl}](${previewUrl})**\n\n` + | |
| `This preview will be updated on every push to this PR.\n\n` + | |
| `---\n` + | |
| `*Deployed by GitHub Actions*`; | |
| // Find existing bot comment | |
| const comments = await github.rest.issues.listComments({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: prNumber, | |
| }); | |
| const botComment = comments.data.find(c => | |
| c.body.includes('Preview Deployment') && c.user.type === 'Bot' | |
| ); | |
| if (botComment) { | |
| await github.rest.issues.updateComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| comment_id: botComment.id, | |
| body: body, | |
| }); | |
| } else { | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: prNumber, | |
| body: body, | |
| }); | |
| } |