Skip to content

Commit 1dad8f8

Browse files
committed
Feat: FE dev 환경 세팅을 위한 cicd 및 환경변수 수정
1 parent 2305e14 commit 1dad8f8

File tree

4 files changed

+294
-5
lines changed

4 files changed

+294
-5
lines changed

.github/workflows/deploy.yml

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ permissions:
44

55
on:
66
push:
7-
branches: [ develop ]
7+
branches: [ develop, main ]
88
tags: [ 'development-**' ]
99
workflow_dispatch:
1010

@@ -16,7 +16,6 @@ jobs:
1616
deploy:
1717
runs-on: ubuntu-latest
1818
env:
19-
NEXT_PUBLIC_BASE_API_URL: ${{ secrets.NEXT_PUBLIC_BASE_API_URL }}
2019
NEXT_PUBLIC_GOOGLE_REDIRECT_CLIENT_ID: ${{ secrets.NEXT_PUBLIC_GOOGLE_REDIRECT_CLIENT_ID }}
2120
NEXT_PUBLIC_GOOGLE_REDIRECT_URI: ${{ secrets.NEXT_PUBLIC_GOOGLE_REDIRECT_URI }}
2221

@@ -30,6 +29,20 @@ jobs:
3029
node-version: '20'
3130
cache: 'yarn' # yarn.lock 기반 자동 캐시
3231

32+
- name: Set env for develop
33+
if: github.ref == 'refs/heads/develop'
34+
run: |
35+
echo "TARGET_BUCKET=${{ secrets.AWS_S3_BUCKET_DEV }}" >> $GITHUB_ENV
36+
echo "NEXT_PUBLIC_APP_ENV=dev" >> $GITHUB_ENV
37+
echo "NEXT_PUBLIC_BASE_API_URL=${{ secrets.NEXT_PUBLIC_BASE_API_URL_DEV }}" >> $GITHUB_ENV
38+
39+
- name: Set env for main
40+
if: github.ref == 'refs/heads/main'
41+
run: |
42+
echo "TARGET_BUCKET=${{ secrets.AWS_S3_BUCKET }}" >> $GITHUB_ENV
43+
echo "NEXT_PUBLIC_APP_ENV=production" >> $GITHUB_ENV
44+
echo "NEXT_PUBLIC_BASE_API_URL=${{ secrets.NEXT_PUBLIC_BASE_API_URL }}" >> $GITHUB_ENV
45+
3346
- name: Install dependencies
3447
run: yarn install --frozen-lockfile
3548

@@ -47,22 +60,22 @@ jobs:
4760
# 프로젝트에 맞게 include/exclude 패턴 조정
4861
- name: Upload static assets (long cache)
4962
run: |
50-
aws s3 cp ./out s3://${{ secrets.AWS_S3_BUCKET }} \
63+
aws s3 cp ./out s3://$TARGET_BUCKET \
5164
--recursive \
5265
--exclude "*" \
5366
--include "_next/**" --include "static/**" --include "assets/**" \
5467
--cache-control "public, max-age=31536000, immutable" \
5568
--metadata-directive REPLACE
5669
- name: Upload html (no cache)
5770
run: |
58-
aws s3 cp ./out s3://${{ secrets.AWS_S3_BUCKET }} \
71+
aws s3 cp ./out s3://$TARGET_BUCKET \
5972
--recursive \
6073
--exclude "_next/*" --exclude "static/*" --exclude "assets/*" \
6174
--cache-control "no-cache" \
6275
--metadata-directive REPLACE
6376
# (단순화 원하면 기존 sync 한 줄 유지 가능)
6477
# - name: Deploy to S3
65-
# run: aws s3 sync ./out s3://${{ secrets.AWS_S3_BUCKET }} --delete
78+
# run: aws s3 sync ./out s3://$TARGET_BUCKET --delete
6679

6780
- name: Invalidate CloudFront Cache
6881
run: |

src/app/layout.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { ErrorBoundary } from "react-error-boundary";
44
import localFont from "next/font/local";
55
import Script from 'next/script';
66
import { NextUIProvider } from "@nextui-org/react";
7+
import DevHeader from "@/components/ui/common/DevHeader";
78

89
// components
910
import Loading from "@/app/loading";
@@ -128,6 +129,7 @@ export default function RootLayout({ children }) {
128129
/>
129130
</head>
130131
<body className={`${pretendard.className} antialiased`}>
132+
{((process.env.NEXT_PUBLIC_APP_ENV ?? process.env.NODE_ENV) !== 'production') && <DevHeader />}
131133
<NextUIProvider>
132134
<ErrorBoundary fallback={<Error />}>
133135
<AuthProvider>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import React from 'react'
2+
3+
export default function DevHeader() {
4+
return (
5+
<>
6+
<div className="fixed top-0 left-0 w-full h-8 bg-transparent text-red-500" style={{zIndex: 999999}}>
7+
<div className="flex justify-between items-center">
8+
<div className="text-2xl font-bold">Dev 서버입니다</div>
9+
</div>
10+
</div>
11+
</>
12+
)
13+
}

0 commit comments

Comments
 (0)