Debugging Preview Function #28
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 Preview | |
| on: | |
| pull_request: | |
| branches: | |
| - main | |
| jobs: | |
| build-and-deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: '22' | |
| - name: Install and export | |
| run: | | |
| npm install | |
| - name: Export site with PR number | |
| run: | | |
| PR_NUMBER=${{ github.event.pull_request.number }} | |
| PR_NUMBER=$PR_NUMBER npm run export | |
| - name: Deploy to GitHub Pages Preview | |
| uses: peaceiris/actions-gh-pages@v4 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_dir: ./out | |
| publish_branch: gh-pages | |
| destination_dir: previews/pr-${{ github.event.pull_request.number }} | |
| force_orphan: false # allows keeping multiple previews | |
| - name: Comment on the PR with the preview link | |
| uses: peter-evans/create-or-update-comment@v3 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| issue-number: ${{ github.event.pull_request.number }} | |
| body: | | |
| 🚀 Preview of the changes is available at: | |
| https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/previews/pr-${{ github.event.pull_request.number }} | |
| edit-mode: replace |