Add CI/CD pipeline: build and deploy to Firebase Hosting#2
Conversation
Agent-Logs-Url: https://github.com/schoedel-learn/LXPython/sessions/8dd33f07-525d-490d-8ee5-3e16c5bb9a34 Co-authored-by: schoedel-learn <212212630+schoedel-learn@users.noreply.github.com>
schoedel-learn
left a comment
There was a problem hiding this comment.
Where do I add these secrets to github
To add secrets to your GitHub repository:
Once |
There was a problem hiding this comment.
Pull request overview
Adds an initial GitHub Actions CI/CD workflow to build the Angular app and deploy it to Firebase Hosting, along with Firebase Hosting project configuration.
Changes:
- Added
firebase.jsonHosting configuration (public dir, SPA rewrites, caching headers). - Added
.firebasercto bind the repo to the target Firebase project. - Added
.github/workflows/deploy.ymlto build on pushes/PRs and deploy preview/live viaaction-hosting-deploy.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
firebase.json |
Configures Firebase Hosting output directory, rewrites, and cache headers. |
.github/workflows/deploy.yml |
Defines the CI build + preview/live deploy workflow. |
.firebaserc |
Sets the default Firebase project ID for deployments. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "rewrites": [ | ||
| { | ||
| "source": "**", | ||
| "destination": "/index.html" | ||
| } |
There was a problem hiding this comment.
This Hosting config rewrites all requests to /index.html, which effectively deploys the app as a pure SPA. Since the app is configured for SSR (outputMode: "server" with an SSR entry in angular.json), this deployment will not run the server renderer (no rewrite to a Cloud Function/Cloud Run endpoint), so SSR won’t actually be used in production. Consider either (a) changing the Firebase rewrites to route all requests to an SSR backend (Functions/Run) or (b) switching the Angular build/deploy to a purely static build if SSR is not intended.
| "headers": [ | ||
| { | ||
| "key": "Cache-Control", | ||
| "value": "max-age=31536000" |
There was a problem hiding this comment.
Cache-Control: max-age=31536000 is missing public (and typically immutable) for long-lived hashed assets. Without public, shared caches/CDNs may not cache as expected, reducing the benefit of the 1-year TTL. Consider setting the value to include public (and immutable if all these assets are content-hashed).
| "value": "max-age=31536000" | |
| "value": "public, max-age=31536000, immutable" |
| env: | ||
| OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} |
There was a problem hiding this comment.
Setting OPENAI_API_KEY as an env var for npm run build likely doesn’t do what the PR description claims: the build script is just ng build, and this repo appears to only pass OPENAI_API_KEY into Angular via --define (see the dev script), not via process env. If the intent is to actually inject the secret into the browser bundle, that would also publish the key to all clients (the app uses OpenAI in the browser with dangerouslyAllowBrowser: true). Consider removing this env var from the build, and instead route OpenAI calls through a server-side component where the key can remain secret (and if you truly need build-time defines, pass them explicitly and only for non-secret values).
| env: | |
| OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} |
| - name: Deploy to Firebase Hosting (Preview) | ||
| if: github.event_name == 'pull_request' | ||
| uses: FirebaseExtended/action-hosting-deploy@v0 | ||
| with: | ||
| repoToken: ${{ secrets.GITHUB_TOKEN }} | ||
| firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT }} | ||
| projectId: gen-lang-client-0879285190 | ||
|
|
There was a problem hiding this comment.
The preview deploy runs on every pull_request event, but FIREBASE_SERVICE_ACCOUNT (and other secrets) are not provided to workflows triggered from forked PRs, which will cause this job to fail for external contributors. Consider guarding the preview deploy step to only run for same-repo PRs (or otherwise handling forks explicitly) so CI stays green.
No build or deployment pipeline existed for this Angular SSR app.
Changes
firebase.jsondist/app/browserindex.htmlfor Angular client-side routingoutputHashing: all).firebasercgen-lang-client-0879285190(pulled from existingfirebase-applet-config.json).github/workflows/deploy.ymlmainand PRs targetingmainnpm ci+npm run build, injectingOPENAI_API_KEYfrom secretsmaindeploy to the live channelGITHUB_TOKENpermissions scoped tocontents: read+pull-requests: writeRequired Secrets
FIREBASE_SERVICE_ACCOUNTOPENAI_API_KEY