|
| 1 | +# Sample workflow for building and deploying a Next.js site to GitHub Pages |
| 2 | +# |
| 3 | +# To get started with Next.js see: https://nextjs.org/docs/getting-started |
| 4 | +# |
| 5 | +name: Deploy Next.js site to Pages |
| 6 | + |
| 7 | +on: |
| 8 | + # Runs on pushes targeting the default branch |
| 9 | + push: |
| 10 | + branches: ["main"] |
| 11 | + |
| 12 | + # Allows you to run this workflow manually from the Actions tab |
| 13 | + workflow_dispatch: |
| 14 | + |
| 15 | +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages |
| 16 | +permissions: |
| 17 | + contents: read |
| 18 | + pages: write |
| 19 | + id-token: write |
| 20 | + |
| 21 | +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. |
| 22 | +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. |
| 23 | +concurrency: |
| 24 | + group: "pages" |
| 25 | + cancel-in-progress: false |
| 26 | + |
| 27 | +jobs: |
| 28 | + # Build job |
| 29 | + build: |
| 30 | + runs-on: ubuntu-latest |
| 31 | + |
| 32 | + steps: |
| 33 | + - name: Checkout |
| 34 | + uses: actions/checkout@v3 |
| 35 | + |
| 36 | + - name: Install Node.js |
| 37 | + uses: actions/setup-node@v3 |
| 38 | + with: |
| 39 | + node-version: 16 |
| 40 | + |
| 41 | + - uses: pnpm/action-setup@v2 |
| 42 | + name: Install pnpm |
| 43 | + id: pnpm-install |
| 44 | + with: |
| 45 | + version: 7 |
| 46 | + run_install: false |
| 47 | + |
| 48 | + - name: Get pnpm store directory |
| 49 | + id: pnpm-cache |
| 50 | + shell: bash |
| 51 | + run: | |
| 52 | + echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT |
| 53 | + - uses: actions/cache@v3 |
| 54 | + name: Setup pnpm cache |
| 55 | + with: |
| 56 | + path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} |
| 57 | + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} |
| 58 | + restore-keys: | |
| 59 | + ${{ runner.os }}-pnpm-store- |
| 60 | + - name: Install dependencies |
| 61 | + run: pnpm install |
| 62 | + |
| 63 | + - name: Setup Pages |
| 64 | + uses: actions/configure-pages@v3 |
| 65 | + with: |
| 66 | + static_site_generator: next |
| 67 | + - name: Build with Next.js |
| 68 | + run: pnpm next build |
| 69 | + - name: Static HTML export with Next.js |
| 70 | + run: pnpm next export |
| 71 | + - name: Upload artifact |
| 72 | + uses: actions/upload-pages-artifact@v4 |
| 73 | + with: |
| 74 | + path: ./out |
| 75 | + |
| 76 | + # Deployment job |
| 77 | + deploy: |
| 78 | + environment: |
| 79 | + name: github-pages |
| 80 | + url: ${{ steps.deployment.outputs.page_url }} |
| 81 | + runs-on: ubuntu-latest |
| 82 | + needs: build |
| 83 | + steps: |
| 84 | + - name: Deploy to GitHub Pages |
| 85 | + id: deployment |
| 86 | + uses: actions/deploy-pages@v2 |
0 commit comments