Skip to content

Commit 2a76606

Browse files
committed
tryin gto fix github action page depployment
1 parent cd0b62d commit 2a76606

File tree

1 file changed

+24
-49
lines changed

1 file changed

+24
-49
lines changed

.github/workflows/nextjs.yml

Lines changed: 24 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,92 +1,67 @@
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
1+
name: Deploy Vite + React App to GitHub Pages
62

73
on:
8-
# Runs on pushes targeting the default branch
94
push:
10-
branches: ["main"]
5+
branches:
6+
- main # or your default branch
117

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
168
permissions:
179
contents: read
1810
pages: write
1911
id-token: write
2012

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.
2313
concurrency:
24-
group: "pages"
25-
cancel-in-progress: false
14+
group: 'pages'
15+
cancel-in-progress: true
2616

2717
jobs:
28-
# Build job
2918
build:
3019
runs-on: ubuntu-latest
3120
steps:
32-
- name: Checkout
21+
- name: Checkout Repository
3322
uses: actions/checkout@v4
34-
- name: Detect package manager
23+
24+
- name: Detect Package Manager
3525
id: detect-package-manager
3626
run: |
3727
if [ -f "${{ github.workspace }}/yarn.lock" ]; then
3828
echo "manager=yarn" >> $GITHUB_OUTPUT
39-
echo "command=install" >> $GITHUB_OUTPUT
29+
echo "install=install" >> $GITHUB_OUTPUT
4030
echo "runner=yarn" >> $GITHUB_OUTPUT
4131
exit 0
42-
elif [ -f "${{ github.workspace }}/package.json" ]; then
32+
elif [ -f "${{ github.workspace }}/package-lock.json" ]; then
4333
echo "manager=npm" >> $GITHUB_OUTPUT
44-
echo "command=ci" >> $GITHUB_OUTPUT
34+
echo "install=ci" >> $GITHUB_OUTPUT
4535
echo "runner=npx --no-install" >> $GITHUB_OUTPUT
4636
exit 0
4737
else
4838
echo "Unable to determine package manager"
4939
exit 1
5040
fi
41+
5142
- name: Setup Node
5243
uses: actions/setup-node@v4
5344
with:
54-
node-version: "20"
45+
node-version: '20'
5546
cache: ${{ steps.detect-package-manager.outputs.manager }}
56-
- name: Setup Pages
57-
uses: actions/configure-pages@v5
58-
with:
59-
# Automatically inject basePath in your Next.js configuration file and disable
60-
# server side image optimization (https://nextjs.org/docs/api-reference/next/image#unoptimized).
61-
#
62-
# You may remove this line if you want to manage the configuration yourself.
63-
static_site_generator: next
64-
- name: Restore cache
65-
uses: actions/cache@v4
66-
with:
67-
path: |
68-
.next/cache
69-
# Generate a new cache whenever packages or source files change.
70-
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
71-
# If source files changed but packages didn't, rebuild from a prior cache.
72-
restore-keys: |
73-
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-
74-
- name: Install dependencies
75-
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
76-
- name: Build with Next.js
77-
run: ${{ steps.detect-package-manager.outputs.runner }} next build
78-
- name: Upload artifact
47+
48+
- name: Install Dependencies
49+
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.install }}
50+
51+
- name: Build Vite App
52+
run: ${{ steps.detect-package-manager.outputs.runner }} vite build
53+
54+
- name: Upload Artifact
7955
uses: actions/upload-pages-artifact@v3
8056
with:
81-
path: ./out
57+
path: dist
8258

83-
# Deployment job
8459
deploy:
60+
needs: build
61+
runs-on: ubuntu-latest
8562
environment:
8663
name: github-pages
8764
url: ${{ steps.deployment.outputs.page_url }}
88-
runs-on: ubuntu-latest
89-
needs: build
9065
steps:
9166
- name: Deploy to GitHub Pages
9267
id: deployment

0 commit comments

Comments
 (0)