Skip to content

Commit

Permalink
Update nextjs.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
arpan-dojima authored Nov 22, 2024
1 parent 3b7666d commit 9caa167
Showing 1 changed file with 11 additions and 19 deletions.
30 changes: 11 additions & 19 deletions .github/workflows/nextjs.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: Deploy Next.js site to Pages
name: Deploy React App to Pages

on:
push:
branches: ["main"]
branches: ["main"] # Replace "main" with your default branch if needed
workflow_dispatch:

permissions:
Expand All @@ -21,6 +21,7 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Detect package manager
id: detect-package-manager
run: |
Expand All @@ -31,39 +32,30 @@ jobs:
exit 0
elif [ -f "${{ github.workspace }}/package.json" ]; then
echo "manager=npm" >> $GITHUB_OUTPUT
echo "command=ci" >> $GITHUB_OUTPUT
echo "command=install" >> $GITHUB_OUTPUT
echo "runner=npx --no-install" >> $GITHUB_OUTPUT
exit 0
else
echo "Unable to determine package manager"
exit 1
fi
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "20"
cache: ${{ steps.detect-package-manager.outputs.manager }}
- name: Setup Pages
uses: actions/configure-pages@v5
with:
static_site_generator: next
- name: Restore cache
uses: actions/cache@v4
with:
path: .next/cache
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-

- name: Install dependencies
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
- name: Build with Next.js
run: ${{ steps.detect-package-manager.outputs.runner }} next build
- name: Export static site
run: ${{ steps.detect-package-manager.outputs.runner }} next export

- name: Build React App
run: npm run build

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./out
path: ./build # React's default build output folder

# Deployment job
deploy:
Expand Down

0 comments on commit 9caa167

Please sign in to comment.