Skip to content

Commit 9b86691

Browse files
committed
added changes to github action file to fix the deployment to github page issue
1 parent 8b5e33b commit 9b86691

1 file changed

Lines changed: 20 additions & 24 deletions

File tree

.github/workflows/nextjs.yml

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,82 @@
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-
#
51
name: Deploy Next.js site to Pages
62

73
on:
8-
# Runs on pushes targeting the default branch
94
push:
105
branches: ["main"]
11-
12-
# Allows you to run this workflow manually from the Actions tab
136
workflow_dispatch:
147

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:
2414
group: "pages"
2515
cancel-in-progress: false
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
23+
3424
- 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
3929
echo "command=install" >> $GITHUB_OUTPUT
4030
echo "runner=yarn" >> $GITHUB_OUTPUT
41-
exit 0
4231
elif [ -f "${{ github.workspace }}/package.json" ]; then
4332
echo "manager=npm" >> $GITHUB_OUTPUT
4433
echo "command=ci" >> $GITHUB_OUTPUT
4534
echo "runner=npx --no-install" >> $GITHUB_OUTPUT
46-
exit 0
4735
else
4836
echo "Unable to determine package manager"
4937
exit 1
5038
fi
51-
- name: Setup Node
39+
40+
- name: Setup Node.js
5241
uses: actions/setup-node@v4
5342
with:
5443
node-version: "20"
5544
cache: ${{ steps.detect-package-manager.outputs.manager }}
45+
5646
- name: Setup Pages
5747
uses: actions/configure-pages@v5
5848
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.
6349
static_site_generator: next
50+
6451
- name: Restore cache
6552
uses: actions/cache@v4
6653
with:
67-
path: |
68-
.next/cache
69-
# Generate a new cache whenever packages or source files change.
54+
path: .next/cache
7055
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.
7256
restore-keys: |
7357
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-
58+
7459
- name: Install dependencies
7560
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
61+
7662
- name: Build with Next.js
7763
run: ${{ steps.detect-package-manager.outputs.runner }} next build
64+
env:
65+
FIREBASE_ADMIN_SDK_KEY: ${{ secrets.FIREBASE_ADMIN_SDK_KEY }}
66+
NEXT_PUBLIC_FIREBASE_API_KEY: ${{ secrets.NEXT_PUBLIC_FIREBASE_API_KEY }}
67+
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN: ${{ secrets.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN }}
68+
NEXT_PUBLIC_FIREBASE_PROJECT_ID: ${{ secrets.NEXT_PUBLIC_FIREBASE_PROJECT_ID }}
69+
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET: ${{ secrets.NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET }}
70+
NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID: ${{ secrets.NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID }}
71+
NEXT_PUBLIC_FIREBASE_APP_ID: ${{ secrets.NEXT_PUBLIC_FIREBASE_APP_ID }}
72+
NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID: ${{ secrets.NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID }}
73+
74+
7875
- name: Upload artifact
7976
uses: actions/upload-pages-artifact@v3
8077
with:
8178
path: ./out
8279

83-
# Deployment job
8480
deploy:
8581
environment:
8682
name: github-pages

0 commit comments

Comments
 (0)