How do I deploy Next.js with GitHub Actions using firebase-framework-tools?
I have successfully deployed the Next.js project by running firebase deploy locally.
However, when I set up GitHub Actions using firebase hosting:github, created a PR, and merged it to main, the following error occurred.
- Must supply a "public" directory or at least one rewrite or redirect in each "hosting" config.
I guessed that this might be due to the fact that --open-sesame frameworkawareness was not applied to the Deploy process performed by FirebaseExtended/action-hosting-deploy@v0, so we changed the GitHub Actions as follows
- run: npm ci && npm run build
+ - run: npm ci && npm run build && . /node_modules/.bin/firebase --open-sesame frameworkawareness
I then encountered the following error regarding GCP permissions
- Permission 'cloudfunctions.functions.list' denied
- Permission 'cloudfunctions.functions.update' denied
- Permission 'cloudfunctions.functions.generateUploadUrl' denied
- Permission 'iam.serviceaccounts.actAs' denied
To solve this error, the following Role was added to the GitHub Actions
- Cloud Functions Developer
- Service Account User
- FirebaseFrameworkTools(Custom Role)
FirebaseFrameworkTools is set to Custom Role and 'cloudfunctions.functions.generateUploadUrl' is added.
If there is another way to do this, or if you have plans to create an Action to replace action-hosting-deploy@v0, I would like to know.
Looks like version 11.13.0 introduced refactored support for the experimental framework.
You need to run firebase experiments:enable webframeworks to activate support for nextjs.
I have the same requirements as you, and I've still yet to get to a full deployment using actions, so will report back if I get it working.
@gladevise I found a working solution to deploy my nextjs SSR app to firebase hosting using the FirebaseExtended/action-hosting-deploy@v0 GitHub action.
Insert the following into your yml file above the - uses: FirebaseExtended/action-hosting-deploy@v0, and it should work.
- name: Install firebase and npm packages
run: npm install -g firebase-tools && firebase experiments:enable webframeworks
There's also an environment variable that is respected
- uses: FirebaseExtended/action-hosting-deploy@v0
with:
# ...
env:
FIREBASE_CLI_EXPERIMENTS: webframeworks