Set base path for GitHub Pages to avoid absolute URL issues #5
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 example page | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
jobs: | |
Build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repo | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: pnpm/action-setup@v4 | |
- name: Setup Node.js 22 | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 22.x | |
cache: pnpm | |
- name: Install Dependencies | |
run: pnpm install --ignore-scripts | |
- name: Cache turbo build setup | |
uses: actions/cache@v4 | |
with: | |
path: node_modules/.cache/turbo | |
key: turbo-${{ github.sha }} | |
restore-keys: | | |
turbo- | |
- name: Build | |
run: pnpm build | |
- name: Build site | |
run: pnpm -dir examples/sandbox build | |
- name: Upload Pages artifact | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
path: examples/sandbox/dist | |
Deploy: | |
needs: Build | |
name: Deploy to Production env | |
runs-on: ubuntu-latest | |
if: ${{ github.event_name == 'push' }} | |
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment | |
permissions: | |
pages: write # to deploy to Pages | |
id-token: write # to verify the deployment originates from an appropriate source | |
environment: | |
name: Production | |
url: ${{ steps.deployment.outputs.page_url }} | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 | |
Deploy_Preview: | |
needs: Build | |
name: Deploy to Preview env | |
runs-on: ubuntu-latest | |
if: ${{ github.event_name == 'pull_request' }} | |
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment | |
permissions: | |
pages: write # to deploy to Pages | |
id-token: write # to verify the deployment originates from an appropriate source | |
environment: | |
name: Preview | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 |