Skip to content

Commit fec9abd

Browse files
chenyuan99claude
andcommitted
fix: consolidate and repair Firebase CI/CD pipelines
- firebase-deploy.yml: add path filters, VITE_RECAPTCHA_ENTERPRISE_SITE_KEY, google-github-actions/auth for SA auth, multi-path npm caching, npx firebase-tools (no global install), remove --debug noise - frontend.yml: drop deploy job (race condition with firebase-deploy.yml), bump all actions to v4, CI-only on PRs and feat/fix branches - backend.yml: drop broken deploy job (was targeting wrong functions dir), fix GOOGLE_APPLICATION_CREDENTIALS misuse, bump actions to v4/v5, CI-only Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 550f70d commit fec9abd

3 files changed

Lines changed: 74 additions & 148 deletions

File tree

.github/workflows/backend.yml

Lines changed: 27 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
name: Backend CI/CD
1+
name: Backend CI
22

33
on:
44
push:
5-
branches: [ main ]
5+
branches: [main, 'feat/**', 'fix/**']
66
paths:
77
- 'backend/**'
88
- '.github/workflows/backend.yml'
99
pull_request:
10-
branches: [ main ]
10+
branches: [main]
1111
paths:
1212
- 'backend/**'
1313
- '.github/workflows/backend.yml'
@@ -20,71 +20,27 @@ jobs:
2020
working-directory: ./backend/parser/functions
2121

2222
steps:
23-
- uses: actions/checkout@v3
24-
25-
- name: Set up Python
26-
uses: actions/setup-python@v4
27-
with:
28-
python-version: '3.12'
29-
cache: 'pip'
30-
cache-dependency-path: './backend/parser/functions/requirements.txt'
31-
32-
- name: Install dependencies
33-
run: |
34-
python -m pip install --upgrade pip
35-
pip install -r requirements.txt
36-
pip install pytest pytest-mock pytest-cov
37-
38-
- name: Run tests with coverage
39-
run: pytest --cov=./ --cov-report=xml
40-
env:
41-
GOOGLE_APPLICATION_CREDENTIALS: ${{ secrets.FIREBASE_SERVICE_ACCOUNT }}
42-
FIREBASE_STORAGE_BUCKET: ${{ secrets.FIREBASE_STORAGE_BUCKET }}
43-
44-
- name: Upload coverage to Codecov
45-
uses: codecov/codecov-action@v3
46-
with:
47-
file: ./coverage.xml
48-
flags: backend
49-
name: backend-coverage
50-
51-
deploy:
52-
needs: test
53-
runs-on: ubuntu-latest
54-
if: github.ref == 'refs/heads/main'
55-
56-
steps:
57-
- uses: actions/checkout@v3
58-
59-
- name: Set up Node.js
60-
uses: actions/setup-node@v3
61-
with:
62-
node-version: '22'
63-
64-
- name: Set up Python
65-
uses: actions/setup-python@v4
66-
with:
67-
python-version: '3.12'
68-
cache: 'pip'
69-
cache-dependency-path: './backend/parser/functions/requirements.txt'
70-
71-
- name: Install Python dependencies
72-
working-directory: ./backend/parser/functions
73-
run: |
74-
python -m pip install --upgrade pip
75-
pip install -r requirements.txt
76-
pip install firebase-admin firebase-functions
77-
78-
- name: Authenticate to Google Cloud
79-
uses: google-github-actions/auth@v1
80-
with:
81-
credentials_json: '${{ secrets.FIREBASE_SERVICE_ACCOUNT }}'
82-
83-
- name: Set up Cloud SDK
84-
uses: google-github-actions/setup-gcloud@v1
85-
86-
- name: Install Firebase CLI
87-
run: npm install -g firebase-tools
88-
89-
- name: Deploy to Firebase Functions
90-
run: firebase deploy --only functions --project ${{ secrets.FIREBASE_PROJECT_ID }} --non-interactive
23+
- uses: actions/checkout@v4
24+
25+
- name: Set up Python
26+
uses: actions/setup-python@v5
27+
with:
28+
python-version: '3.12'
29+
cache: 'pip'
30+
cache-dependency-path: './backend/parser/functions/requirements.txt'
31+
32+
- name: Install dependencies
33+
run: |
34+
python -m pip install --upgrade pip
35+
pip install -r requirements.txt
36+
pip install pytest pytest-mock pytest-cov
37+
38+
- name: Run tests with coverage
39+
run: pytest --cov=./ --cov-report=xml
40+
41+
- name: Upload coverage to Codecov
42+
uses: codecov/codecov-action@v4
43+
with:
44+
file: ./coverage.xml
45+
flags: backend
46+
name: backend-coverage

.github/workflows/firebase-deploy.yml

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,19 @@ name: Deploy to Firebase
33
on:
44
push:
55
branches: [main]
6+
paths:
7+
- 'frontend/**'
8+
- 'functions/**'
9+
- 'firebase.json'
10+
- '.github/workflows/firebase-deploy.yml'
611
workflow_dispatch:
712

813
jobs:
914
deploy:
1015
runs-on: ubuntu-latest
16+
permissions:
17+
contents: read
18+
id-token: write
1119

1220
steps:
1321
- uses: actions/checkout@v4
@@ -17,7 +25,9 @@ jobs:
1725
with:
1826
node-version: '22'
1927
cache: 'npm'
20-
cache-dependency-path: frontend/package-lock.json
28+
cache-dependency-path: |
29+
frontend/package-lock.json
30+
functions/package-lock.json
2131
2232
- name: Install frontend dependencies
2333
run: npm ci --prefix frontend
@@ -32,19 +42,21 @@ jobs:
3242
VITE_FIREBASE_MESSAGING_SENDER_ID: ${{ secrets.VITE_FIREBASE_MESSAGING_SENDER_ID }}
3343
VITE_FIREBASE_APP_ID: ${{ secrets.VITE_FIREBASE_APP_ID }}
3444
VITE_FIREBASE_MEASUREMENT_ID: ${{ secrets.VITE_FIREBASE_MEASUREMENT_ID }}
45+
VITE_RECAPTCHA_ENTERPRISE_SITE_KEY: ${{ secrets.VITE_RECAPTCHA_ENTERPRISE_SITE_KEY }}
3546

3647
- name: Install functions dependencies
3748
run: npm ci --prefix functions
3849

3950
- name: Build functions
4051
run: npm run build --prefix functions
4152

53+
- name: Authenticate to Google Cloud
54+
uses: google-github-actions/auth@v2
55+
with:
56+
credentials_json: ${{ secrets.FIREBASE_SERVICE_ACCOUNT }}
57+
58+
- name: Write functions env
59+
run: echo "GOOGLE_GENAI_API_KEY=${{ secrets.GOOGLE_GENAI_API_KEY }}" > functions/.env.taxfront-1e142
60+
4261
- name: Deploy to Firebase
43-
run: |
44-
echo '${{ secrets.FIREBASE_SERVICE_ACCOUNT }}' > /tmp/sa.json
45-
echo "GOOGLE_GENAI_API_KEY=${{ secrets.GOOGLE_GENAI_API_KEY }}" > functions/.env.taxfront-1e142
46-
npm install -g firebase-tools
47-
GOOGLE_APPLICATION_CREDENTIALS=/tmp/sa.json firebase deploy --project taxfront-1e142 --non-interactive --debug 2>&1
48-
EXIT=$?
49-
rm -f /tmp/sa.json functions/.env.taxfront-1e142
50-
exit $EXIT
62+
run: npx firebase-tools deploy --project taxfront-1e142 --non-interactive

.github/workflows/frontend.yml

Lines changed: 26 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
name: Frontend CI/CD
1+
name: Frontend CI
22

33
on:
44
push:
5-
branches: [ main, 'feature/**' ]
5+
branches: ['feat/**', 'fix/**']
66
paths:
77
- 'frontend/**'
88
- '.github/workflows/frontend.yml'
99
pull_request:
10-
branches: [ main, 'feature/**' ]
10+
branches: [main]
1111
paths:
1212
- 'frontend/**'
1313
- '.github/workflows/frontend.yml'
@@ -20,70 +20,28 @@ jobs:
2020
working-directory: ./frontend
2121

2222
steps:
23-
- uses: actions/checkout@v3
24-
25-
- name: Set up Node.js
26-
uses: actions/setup-node@v3
27-
with:
28-
node-version: '22'
29-
cache: 'npm'
30-
cache-dependency-path: './frontend/package-lock.json'
31-
32-
- name: Install dependencies
33-
run: npm ci
34-
35-
- name: Run linter
36-
run: npm run lint
37-
38-
- name: Run tests with coverage
39-
run: npm test -- --coverage
40-
env:
41-
CI: true
42-
43-
- name: Upload coverage to Codecov
44-
uses: codecov/codecov-action@v3
45-
with:
46-
flags: frontend
47-
name: frontend-coverage
23+
- uses: actions/checkout@v4
4824

49-
deploy:
50-
needs: test
51-
runs-on: ubuntu-latest
52-
if: github.ref == 'refs/heads/main'
53-
defaults:
54-
run:
55-
working-directory: ./frontend
25+
- name: Set up Node.js
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: '22'
29+
cache: 'npm'
30+
cache-dependency-path: './frontend/package-lock.json'
5631

57-
steps:
58-
- uses: actions/checkout@v3
59-
60-
- name: Set up Node.js
61-
uses: actions/setup-node@v3
62-
with:
63-
node-version: '22'
64-
cache: 'npm'
65-
cache-dependency-path: './frontend/package-lock.json'
66-
67-
- name: Install dependencies
68-
run: npm ci
69-
70-
- name: Build
71-
run: npm run build
72-
env:
73-
VITE_FIREBASE_API_KEY: ${{ secrets.FIREBASE_APIKEY }}
74-
VITE_FIREBASE_AUTH_DOMAIN: ${{ secrets.FIREBASE_AUTH_DOMAIN }}
75-
VITE_FIREBASE_PROJECT_ID: ${{ secrets.FIREBASE_PROJECT_ID }}
76-
VITE_FIREBASE_STORAGE_BUCKET: ${{ secrets.FIREBASE_STORAGE_BUCKET }}
77-
VITE_FIREBASE_MESSAGING_SENDER_ID: ${{ secrets.FIREBASE_MESSAGING_SENDER_ID }}
78-
VITE_FIREBASE_APP_ID: ${{ secrets.FIREBASE_APP_ID }}
79-
VITE_FIREBASE_MEASUREMENT_ID: ${{ secrets.FIREBASE_MEASUREMENT_ID }}
80-
81-
- name: Deploy to Firebase
82-
uses: FirebaseExtended/action-hosting-deploy@v0
83-
with:
84-
repoToken: '${{ secrets.GITHUB_TOKEN }}'
85-
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT }}'
86-
channelId: live
87-
projectId: ${{ secrets.FIREBASE_PROJECT_ID }}
88-
env:
89-
FIREBASE_CLI_EXPERIMENTS: webframeworks
32+
- name: Install dependencies
33+
run: npm ci
34+
35+
- name: Run linter
36+
run: npm run lint
37+
38+
- name: Run tests with coverage
39+
run: npm test -- --coverage
40+
env:
41+
CI: true
42+
43+
- name: Upload coverage to Codecov
44+
uses: codecov/codecov-action@v4
45+
with:
46+
flags: frontend
47+
name: frontend-coverage

0 commit comments

Comments
 (0)