fix script #6
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
# .github/workflows/deploy.yml | |
name: Deploy Nextra Site to GitHub Pages | |
on: | |
push: | |
branches: ["main"] | |
workflow_dispatch: | |
permissions: | |
contents: read | |
pages: write | |
id-token: write | |
concurrency: | |
group: "pages" | |
cancel-in-progress: false | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [20] | |
steps: | |
# 1. Checkout the repository | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
# 2. Setup Node.js | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: "pnpm" | |
# 3. Setup pnpm | |
- name: Setup pnpm | |
uses: pnpm/action-setup@v4 | |
with: | |
version: 10 # Specify the desired pnpm version | |
# 4. Restore Cache | |
- name: Restore Cache | |
uses: actions/cache@v4 | |
with: | |
path: | | |
.next/cache | |
~/.pnpm-store | |
key: ${{ runner.os }}-nextra-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**/*.js', '**/*.ts', '**/*.jsx', '**/*.tsx') }} | |
restore-keys: | | |
${{ runner.os }}-nextra- | |
# 5. Install Dependencies using pnpm | |
- name: Install Dependencies | |
run: pnpm install | |
# 6. Build the Site | |
- name: Build the Site | |
run: pnpm build | |
# 7. Add .nojekyll to Prevent Jekyll Processing | |
- name: Add .nojekyll | |
run: touch ./docs/.nojekyll | |
# 8. Upload the Build Artifact | |
- name: Upload Build Artifact | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
path: ./docs # Ensure this matches your build output directory | |
deploy: | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
# 9. Deploy to GitHub Pages | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 |