FirebaseExtended / action-hosting-deploy

Automatically deploy shareable previews for your Firebase Hosting sites
https://firebase.google.com/docs/hosting/github-integration
Apache License 2.0
691 stars 201 forks source link

Possibility to Deploy SSR (Next.js) app with github action #265

Open alekseykarpenko opened 1 year ago

alekseykarpenko commented 1 year ago

The use case you're trying to solve

I have my GitHub action config generated alongside with setting up webframeworks support for SSR app (Next.js). When I deploy the app manually it all works as expected, but when using FirebaseExtended/action-hosting-deploy it leads to getting 404 for all dynamic pages (while static content works fine).

A quick search on this topic showed up that this GitHub action doesn't yet support deploying of Cloud Functions, that's why all the dynamic part of the app is being constantly lost during deployment. But since everything is being deployed correctly, seems Previews already support dynamic content through Cloud Functions.

Change to the action that would solve that use case

There is already a potential fix for this in opened PRs: https://github.com/FirebaseExtended/action-hosting-deploy/pull/190

steebchen commented 1 year ago

This would be so great to have!

dannydeut commented 1 year ago

I got this to work by adding the environment variable FIREBASE_CLI_EXPERIMENTS which is part of firebase-tools.

- name: Deploy to Firebase
  uses: FirebaseExtended/action-hosting-deploy@v0
  with:
    repoToken: '${{ secrets.GITHUB_TOKEN }}'
    firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT }}'
    channelId: live
    projectId: ...
  env:
    FIREBASE_CLI_EXPERIMENTS: webframeworks
steebchen commented 1 year ago

@dannydeut Yeah, this fixes the issue when using a standalone Next app without any functions (or SSR as that uses functions), which is why this issue is still relevant. But thanks for the comment, as it's maybe helpful for other people running into this without using functions!

robokozo commented 1 year ago

I'm doing deployments with https://nitro.unjs.io/deploy/providers/firebase and it'd be cool to have this integration support it too

art-ash commented 1 year ago

Really hope this enhancement will be implemented. We switched from hosting on Vercel to Firebase, and inability to deploy via GitHub Actions, makes me feel that this decision was premature

steebchen commented 1 year ago

Just for everyone's information, it works with the latest firebase CLI with two manual changes:

1) add additional permissions manually to the firebase service account which the CLI creates:

2) set an env var in the action (FIREBASE_CLI_EXPERIMENTS: webframeworks,pintags)

Obviously, it would be great to make this work fully automatically and ideally also have a test case for it, but the manual workaround doea the trick for now.

art-ash commented 1 year ago

@steebchen apart from mentioned, in my case, I also needed to grant the created by CLI "github-action-service-account" with "Service Account User" role (roles/iam.serviceAccountUser). The action always failed without it. Maybe that's because I started configuring this workflow without Admin role (not sure, I'm new to GCP)

knownasilya commented 1 year ago

Can you deploy functions with this? Not NEXT specific that is.

jrnkng commented 11 months ago

Its works for me expect the images do not show up (can't find any). But when I deploy via the firebase CLI images do work. Anyone knows why? /