-
Notifications
You must be signed in to change notification settings - Fork 0
Add CI/CD pipeline: build and deploy to Firebase Hosting #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "projects": { | ||
| "default": "gen-lang-client-0879285190" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| name: Build and Deploy to Firebase Hosting | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| pull_request: | ||
| branches: | ||
| - main | ||
|
|
||
| jobs: | ||
| build_and_deploy: | ||
| name: Build and Deploy | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| pull-requests: write | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '20' | ||
| cache: 'npm' | ||
|
|
||
| - name: Install dependencies | ||
| run: npm ci | ||
|
|
||
| - name: Build application | ||
| run: npm run build | ||
| 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 | ||
|
|
||
|
Comment on lines
+37
to
+44
|
||
| - name: Deploy to Firebase Hosting (Live) | ||
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | ||
| uses: FirebaseExtended/action-hosting-deploy@v0 | ||
| with: | ||
| repoToken: ${{ secrets.GITHUB_TOKEN }} | ||
| firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT }} | ||
| projectId: gen-lang-client-0879285190 | ||
| channelId: live | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,27 @@ | ||||||
| { | ||||||
| "hosting": { | ||||||
| "public": "dist/app/browser", | ||||||
| "ignore": [ | ||||||
| "firebase.json", | ||||||
| "**/.*", | ||||||
| "**/node_modules/**" | ||||||
| ], | ||||||
| "rewrites": [ | ||||||
| { | ||||||
| "source": "**", | ||||||
| "destination": "/index.html" | ||||||
| } | ||||||
|
Comment on lines
+9
to
+13
|
||||||
| ], | ||||||
| "headers": [ | ||||||
| { | ||||||
| "source": "**/*.@(js|css|mjs)", | ||||||
| "headers": [ | ||||||
| { | ||||||
| "key": "Cache-Control", | ||||||
| "value": "max-age=31536000" | ||||||
|
||||||
| "value": "max-age=31536000" | |
| "value": "public, max-age=31536000, immutable" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setting
OPENAI_API_KEYas an env var fornpm run buildlikely doesn’t do what the PR description claims: thebuildscript is justng build, and this repo appears to only passOPENAI_API_KEYinto Angular via--define(see thedevscript), 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 withdangerouslyAllowBrowser: 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).