Debugging Preview Function #30
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: Set WEBSITE_BASE_PATH env variable | |
| run: | | |
| echo "WEBSITE_BASE_PATH=/previews/pr-${{ github.event.pull_request.number }}" >> $GITHUB_ENV | |
| - name: Install and export | |
| run: | | |
| npm install | |
| 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 | |
| - 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 |