chore(app): update GitHub Pages deployment workflow for app #1
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 Next.js to GitHub Pages | |
| on: | |
| push: | |
| branches: | |
| - app # Set a branch to deploy | |
| # Allows you to run this workflow manually from the Actions tab | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: "pages" | |
| cancel-in-progress: true | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Detect package manager | |
| id: detect-package-manager | |
| run: | | |
| if [ -f "yarn.lock" ]; then | |
| echo "manager=yarn" >> $GITHUB_OUTPUT | |
| echo "command=yarn --frozen-lockfile" >> $GITHUB_OUTPUT | |
| echo "runner=yarn" | |
| elif [ -f "pnpm-lock.yaml" ]; then | |
| echo "manager=pnpm" >> $GITHUB_OUTPUT | |
| echo "command=pnpm install --frozen-lockfile" >> $GITHUB_OUTPUT | |
| echo "runner=pnpm" | |
| else | |
| echo "manager=npm" >> $GITHUB_OUTPUT | |
| echo "command=npm ci" >> $GITHUB_OUTPUT | |
| echo "runner=npx --no-install" | |
| fi | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| cache: ${{ steps.detect-package-manager.outputs.manager }} | |
| - name: Restore cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| .next/cache | |
| key: ${{ runner.os }}-nextjs-${{ hashFiles('**/lock.json') }}-${{ hashFiles('**/*.ts', '**/*.tsx', '**/*.js') }}-${{ hashFiles('**/*.css') }} | |
| restore-keys: | | |
| ${{ runner.os }}-nextjs-${{ hashFiles('**/lock.json') }}- | |
| - name: Install dependencies | |
| run: ${{ steps.detect-package-manager.outputs.command }} | |
| - name: Build with Next.js | |
| run: ${{ steps.detect-package-manager.outputs.runner }} next build | |
| - name: Static HTML export with Next.js | |
| run: ${{ steps.detect-package-manager.outputs.runner }} next export | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: ./out | |
| deploy: | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |