I’m trying to implement CI/CD for a simple NextJS app router with Firebase. Of course, Firebase SA credentials are not recommended to be pushed into repos. I am unable to build the app as one my file imports the missing credentials. The main issue is that I kept trying to create the SA cred file from within my GitHub Actions workflow but it still couldn’t find the file. I’ve already stored the GitHub environment variables.
Directories
root(appname)/firebase/server.ts // File that imports the SA creds
root(appname)/firebase/serviceAccount.json
- name: Create SA Creds File
run: |
mkdir -p ./firebase
echo '${{ secrets.SA_CREDS }}' > ./firebase/serviceAccount.json
> [email protected] build
> next build
Attention: Next.js now collects completely anonymous telemetry regarding usage.
This information is used to shape Next.js' roadmap and prioritize features.
You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
https://nextjs.org/telemetry
▲ Next.js 14.2.4
- Environments: .env
Creating an optimized production build ...
Failed to compile.
./firebase/server.ts
Module not found: Can't resolve './serviceAccount.json'
https://nextjs.org/docs/messages/module-not-found
Import trace for requested module:
./app/page.tsx
> Build failed because of webpack errors
I found this from
Google services json file for github actions?
I’ve tried it but outcome remains the same
- name: Create file
run: cat /home/runner/work/appname/appname/firebase/serviceAccount.json | base64
- name: Putting data
env:
DATA: ${{ secrets.NEXT_SERVICE_ACCOUNT }}
run: echo $DATA > /home/runner/work/appname/appname/firebase/serviceAccount.json