Skip to content

Commit b7569bf

Browse files
authored
Merge pull request #54 from f-lab-edu/refactoring
S3 배포 및 PR 타입 체크 워크플로우 추가
2 parents 617d6a4 + 6b789c4 commit b7569bf

File tree

5 files changed

+183
-4
lines changed

5 files changed

+183
-4
lines changed

.github/SECURITY.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## GitHub Actions 보안 정책
2+
3+
- GitHub 공식 Actions: 태그 버전 사용 (@v4)
4+
- 써드파티 Actions: 태그 버전 사용 (@v4)
5+
- 주간 보안 업데이트 체크

.github/dependabot.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
# 써드파티 Actions만 pin
8+
ignore:
9+
- dependency-name: "actions/*"
10+
update-types: ["version-update:semver-major"]
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# .github/workflows/deploy-optimized.yml
2+
name: Deploy to S3 (Optimized)
3+
4+
on:
5+
push:
6+
branches: [main]
7+
8+
env:
9+
AWS_REGION: ap-northeast-2
10+
BUILD_DIR: ./apps/watcha_clone_coding/dist
11+
12+
jobs:
13+
deploy:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
20+
- name: Setup Node.js
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: '22.13.0'
24+
25+
- name: Setup pnpm
26+
uses: pnpm/action-setup@v4
27+
with:
28+
version: '10.15.1'
29+
30+
- name: Get pnpm store directory
31+
shell: bash
32+
run: |
33+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
34+
35+
- name: Setup pnpm cache
36+
uses: actions/cache@v4
37+
with:
38+
path: ${{ env.STORE_PATH }}
39+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
40+
restore-keys: |
41+
${{ runner.os }}-pnpm-store-
42+
43+
- name: Install dependencies
44+
run: pnpm install --frozen-lockfile
45+
46+
- name: Build workspace packages
47+
run: |
48+
echo "=== 워크스페이스 패키지들 빌드 ==="
49+
pnpm --filter @watcha/carousel build
50+
51+
- name: Run type check
52+
run: pnpm type-check
53+
54+
- name: Build for production
55+
run: pnpm build:production
56+
57+
- name: Configure AWS credentials
58+
uses: aws-actions/configure-aws-credentials@v4
59+
with:
60+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
61+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
62+
aws-region: ${{ env.AWS_REGION }}
63+
64+
- name: Deploy to S3 with optimized settings
65+
env:
66+
S3_BUCKET_NAME: ${{ secrets.S3_BUCKET_NAME }}
67+
run: |
68+
# HTML 파일 업로드 - 캐시 비활성화
69+
aws s3 sync ${{ env.BUILD_DIR }} s3://$S3_BUCKET_NAME \
70+
--exclude "*" \
71+
--include "*.html" \
72+
--cache-control "max-age=0,must-revalidate,public" \
73+
--content-type "text/html; charset=utf-8" \
74+
--delete
75+
76+
# CSS 파일 업로드 - 1년 캐시
77+
aws s3 sync ${{ env.BUILD_DIR }} s3://$S3_BUCKET_NAME \
78+
--exclude "*" \
79+
--include "*.css" \
80+
--cache-control "max-age=31536000,public" \
81+
--content-type "text/css; charset=utf-8"
82+
83+
# JS 파일 업로드 - 1년 캐시
84+
aws s3 sync ${{ env.BUILD_DIR }} s3://$S3_BUCKET_NAME \
85+
--exclude "*" \
86+
--include "*.js" \
87+
--cache-control "max-age=31536000,public" \
88+
--content-type "application/javascript; charset=utf-8"
89+
90+
# 기타 파일들 (이미지, 폰트 등) 업로드 - 1년 캐시
91+
aws s3 sync ${{ env.BUILD_DIR }} s3://$S3_BUCKET_NAME \
92+
--exclude "*.html" \
93+
--exclude "*.css" \
94+
--exclude "*.js" \
95+
--cache-control "max-age=31536000,public"
96+
97+
- name: Invalidate CloudFront
98+
if: ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID != '' }}
99+
env:
100+
CLOUDFRONT_DISTRIBUTION_ID: ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }}
101+
run: |
102+
aws cloudfront create-invalidation \
103+
--distribution-id $CLOUDFRONT_DISTRIBUTION_ID \
104+
--paths "/*.html" "/*.css" "/*.js"

.github/workflows/pr-check.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# .github/workflows/pr-check.yml
2+
name: PR Type Check
3+
4+
on:
5+
pull_request:
6+
branches: [main, develop]
7+
8+
jobs:
9+
type-check:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
16+
- name: Setup Node.js
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version: '22.13.0'
20+
21+
- name: Setup pnpm
22+
uses: pnpm/action-setup@v4
23+
with:
24+
version: '10.15.1'
25+
26+
- name: Get pnpm store directory
27+
shell: bash
28+
run: |
29+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
30+
31+
- name: Setup pnpm cache
32+
uses: actions/cache@v4
33+
with:
34+
path: ${{ env.STORE_PATH }}
35+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
36+
restore-keys: |
37+
${{ runner.os }}-pnpm-store-
38+
39+
- name: Install dependencies
40+
run: pnpm install --frozen-lockfile
41+
42+
- name: Debug - 환경 확인
43+
run: |
44+
echo "Node.js: $(node --version)"
45+
echo "pnpm: $(pnpm --version)"
46+
echo "작업 디렉토리: $(pwd)"
47+
echo "패키지 목록:"
48+
pnpm list -r --depth=0
49+
50+
- name: Build workspace packages
51+
run: |
52+
echo "=== 워크스페이스 패키지들 빌드 ==="
53+
# carousel 패키지 빌드 (타입 선언 파일 생성)
54+
pnpm --filter @watcha/carousel build
55+
56+
- name: Run type check
57+
run: pnpm type-check
58+
59+
- name: Run lint
60+
run: pnpm lint

apps/watcha_clone_coding/src/pages/ListPage.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const ListPageContent = () => {
3939
<Carousel.LeftButton />
4040
<Carousel.Track articleWidth={1140}>
4141
<Carousel.Article articleWidth={1140} layout="overlay">
42-
{(slide) => {
42+
{(slide: any) => {
4343
return <MovieCard slide={slide as CarouselProps} layout="overlay" type="movie" />;
4444
}}
4545
</Carousel.Article>
@@ -53,7 +53,7 @@ const ListPageContent = () => {
5353
<Carousel.LeftButton />
5454
<Carousel.Track articleWidth={421}>
5555
<Carousel.Article articleWidth={421} layout="top">
56-
{(slide) => {
56+
{(slide: any) => {
5757
return <MovieCard slide={slide as CarouselProps} layout="top" type="movie" />;
5858
}}
5959
</Carousel.Article>
@@ -67,7 +67,7 @@ const ListPageContent = () => {
6767
<Carousel.LeftButton />
6868
<Carousel.Track articleWidth={400}>
6969
<Carousel.Article articleWidth={400} layout="left">
70-
{(slide) => {
70+
{(slide: any) => {
7171
return <MovieCard slide={slide as CarouselProps} layout="left" type="movie" />;
7272
}}
7373
</Carousel.Article>
@@ -81,7 +81,7 @@ const ListPageContent = () => {
8181
<Carousel.LeftButton />
8282
<Carousel.Track articleWidth={290}>
8383
<Carousel.Article articleWidth={290} layout="none">
84-
{(slide) => {
84+
{(slide: any) => {
8585
return <MovieCard slide={slide as CarouselProps} layout="none" type="movie" />;
8686
}}
8787
</Carousel.Article>

0 commit comments

Comments
 (0)