Skip to content

Commit 5af4f47

Browse files
authored
Merge pull request #55 from TTORANG/chore/firebase-hosting#53
chore: Firebase 배포 설정 개선 (#53)
2 parents 9061039 + 55f6606 commit 5af4f47

File tree

6 files changed

+105
-17
lines changed

6 files changed

+105
-17
lines changed

.env.development

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# 개발 서버 (배포된 개발 환경)
2+
VITE_API_URL=https://dev-api.ttorang.com
3+
VITE_APP_TITLE=또랑 (개발)

.env.example

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
1+
# ===========================================
2+
# 환경변수 템플릿
3+
# 이 파일을 복사해서 .env.local 파일을 만드세요
4+
# ===========================================
15

2-
# API
6+
# API 서버 URL
7+
# - 개발: https://dev-api.ttorang.com
8+
# - 프로덕션: https://api.ttorang.com
39
VITE_API_URL=
410

5-
# App
11+
# 앱 타이틀
612
VITE_APP_TITLE=또랑
13+
14+
# ===========================================
15+
# 시크릿 키 (반드시 .env.local에만 설정하세요)
16+
# ===========================================
17+
18+
# 카카오 JavaScript 키 (공유 기능용)
19+
# https://developers.kakao.com 에서 발급
20+
VITE_KAKAO_JS_KEY=

.env.production

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# 프로덕션 서버
2+
VITE_API_URL=https://api.ttorang.com
3+
VITE_APP_TITLE=또랑

.github/workflows/firebase-hosting-merge.yml

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,33 @@
1-
# This file was auto-generated by the Firebase CLI
2-
# https://github.com/firebase/firebase-tools
3-
41
name: Deploy to Firebase Hosting on merge
2+
53
on:
64
push:
75
branches:
86
- main
7+
98
jobs:
109
build_and_deploy:
1110
runs-on: ubuntu-latest
1211
steps:
1312
- uses: actions/checkout@v4
14-
- run: npm ci && npm run build
15-
- uses: FirebaseExtended/action-hosting-deploy@v0
13+
14+
- name: Setup Node.js
15+
uses: actions/setup-node@v4
16+
with:
17+
node-version-file: '.nvmrc'
18+
cache: 'npm'
19+
20+
- name: Install dependencies
21+
run: npm ci
22+
23+
- name: Build
24+
run: npm run build
25+
env:
26+
VITE_API_URL: ${{ secrets.VITE_API_URL }}
27+
VITE_KAKAO_JS_KEY: ${{ secrets.VITE_KAKAO_JS_KEY }}
28+
29+
- name: Deploy to Firebase
30+
uses: FirebaseExtended/action-hosting-deploy@v0
1631
with:
1732
repoToken: ${{ secrets.GITHUB_TOKEN }}
1833
firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_TTORANG }}

.github/workflows/firebase-hosting-pull-request.yml

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,36 @@
1-
# This file was auto-generated by the Firebase CLI
2-
# https://github.com/firebase/firebase-tools
3-
41
name: Deploy to Firebase Hosting on PR
2+
53
on: pull_request
4+
65
permissions:
76
checks: write
87
contents: read
98
pull-requests: write
9+
1010
jobs:
1111
build_and_preview:
1212
if: ${{ github.event.pull_request.head.repo.full_name == github.repository }}
1313
runs-on: ubuntu-latest
1414
steps:
1515
- uses: actions/checkout@v4
16-
- run: npm ci && npm run build
17-
- uses: FirebaseExtended/action-hosting-deploy@v0
16+
17+
- name: Setup Node.js
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version-file: '.nvmrc'
21+
cache: 'npm'
22+
23+
- name: Install dependencies
24+
run: npm ci
25+
26+
- name: Build
27+
run: npm run build
28+
env:
29+
VITE_API_URL: ${{ secrets.VITE_API_URL }}
30+
VITE_KAKAO_JS_KEY: ${{ secrets.VITE_KAKAO_JS_KEY }}
31+
32+
- name: Deploy Preview to Firebase
33+
uses: FirebaseExtended/action-hosting-deploy@v0
1834
with:
1935
repoToken: ${{ secrets.GITHUB_TOKEN }}
2036
firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_TTORANG }}

firebase.json

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,53 @@
11
{
22
"hosting": {
33
"public": "dist",
4-
"ignore": [
5-
"firebase.json",
6-
"**/.*",
7-
"**/node_modules/**"
8-
],
4+
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
95
"rewrites": [
106
{
117
"source": "**",
128
"destination": "/index.html"
139
}
10+
],
11+
"headers": [
12+
{
13+
"source": "**/*.@(js|css|jpg|jpeg|png|gif|webp|svg|ico|woff|woff2)",
14+
"headers": [
15+
{
16+
"key": "Cache-Control",
17+
"value": "public, max-age=31536000, immutable"
18+
}
19+
]
20+
},
21+
{
22+
"source": "index.html",
23+
"headers": [
24+
{
25+
"key": "Cache-Control",
26+
"value": "no-cache, no-store, must-revalidate"
27+
}
28+
]
29+
},
30+
{
31+
"source": "**",
32+
"headers": [
33+
{
34+
"key": "Content-Security-Policy",
35+
"value": "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; font-src 'self' data:; connect-src 'self' https://dev-api.ttorang.com https://api.ttorang.com https://developers.kakao.com; frame-ancestors 'none'"
36+
},
37+
{
38+
"key": "X-Frame-Options",
39+
"value": "DENY"
40+
},
41+
{
42+
"key": "X-Content-Type-Options",
43+
"value": "nosniff"
44+
},
45+
{
46+
"key": "Referrer-Policy",
47+
"value": "strict-origin-when-cross-origin"
48+
}
49+
]
50+
}
1451
]
1552
}
1653
}

0 commit comments

Comments
 (0)