Skip to content

(#246) monthViewWithData 컴포넌트 설계 변경 #430

(#246) monthViewWithData 컴포넌트 설계 변경

(#246) monthViewWithData 컴포넌트 설계 변경 #430

Workflow file for this run

name: CI/CD
on:
push:
paths:
- '**'
workflow_dispatch:
permissions:
contents: read
env:
LONG_CACHE: '--cache-control public,max-age=31536000,immutable'
SHORT_CACHE: '--cache-control public,max-age=0,no-cache,must-revalidate'
S3_SYNC_OPTS: '--delete'
jobs:
client-CI-CD:
runs-on: ubuntu-latest
steps:
- name: Checkout Branch
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: 'npm'
cache-dependency-path: package-lock.json
- name: Create .env
run: |
echo "ref = $GITHUB_REF"
if [ "$GITHUB_REF" = "refs/heads/main" ]; then
echo "${{ secrets.MAIN_ENV }}" > .env
else
echo "${{ secrets.DEV_ENV }}" > .env
fi
- name: Prepare Manifest
run: |
if [ "$GITHUB_REF" = "refs/heads/main" ]; then
echo "Using production manifest"
cp manifest.prod.json public/manifest.json
else
echo "Using development manifest"
cp manifest.dev.json public/manifest.json
fi
- name: Build and Export
run: |
npm install
npm run build
- name: Set deploy env vars
id: setenv
run: |
if [[ "${GITHUB_REF}" == "refs/heads/main" ]]; then
echo "TARGET=main" >> "$GITHUB_OUTPUT"
elif [[ "${GITHUB_REF}" == "refs/heads/develop" ]]; then
echo "TARGET=dev" >> "$GITHUB_OUTPUT"
else
echo "TARGET=none" >> "$GITHUB_OUTPUT"
fi
- name: Configure AWS credentials
if: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' }}
uses: aws-actions/configure-aws-credentials@v3
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Upload assets to S3 (MAIN)
if: ${{ github.ref == 'refs/heads/main' }}
run: |
BUCKET=${{ secrets.AWS_S3_CLIENT_MAIN_BUCKET_NAME }}
# 1. 롱 캐시: 서비스 워커 파일들(sw.js, firebase-messaging-sw.js)을 제외하고 업로드
aws s3 sync ./out s3://$BUCKET \
--exclude "*.html" --exclude "*.txt" --exclude "legal/*" \
--exclude "sw.js" --exclude "firebase-messaging-sw.js" \
$LONG_CACHE $S3_SYNC_OPTS
# 2. 숏 캐시: HTML 파일들
aws s3 sync ./out s3://$BUCKET \
--exclude "*" --include "*.html" --exclude "legal/*" \
$SHORT_CACHE $S3_SYNC_OPTS \
--content-type "text/html"
# 3. 숏 캐시: 서비스 워커 파일들 (새로 추가된 핵심 부분)
aws s3 sync ./out s3://$BUCKET \
--exclude "*" --include "sw.js" --include "firebase-messaging-sw.js" \
$SHORT_CACHE $S3_SYNC_OPTS
# 4. 숏 캐시: robots.txt
if [ -f ./out/robots.txt ]; then
aws s3 cp ./out/robots.txt s3://$BUCKET/robots.txt $SHORT_CACHE
fi
- name: Invalidate CloudFront cache (MAIN)
if: ${{ github.ref == 'refs/heads/main' }}
run: |
aws cloudfront create-invalidation \
--distribution-id ${{ secrets.AWS_CLOUDFRONT_MAIN_DISTRIBUTION_ID }} \
--paths "/*"
- name: Upload assets to S3 (DEV)
if: ${{ github.ref == 'refs/heads/develop' }}
run: |
BUCKET=${{ secrets.AWS_S3_CLIENT_DEV_BUCKET_NAME }}
# 1. 롱 캐시: 서비스 워커 파일들(sw.js, firebase-messaging-sw.js)을 제외하고 업로드
aws s3 sync ./out s3://$BUCKET \
--exclude "*.html" --exclude "*.txt" --exclude "legal/*" \
--exclude "sw.js" --exclude "firebase-messaging-sw.js" \
$LONG_CACHE $S3_SYNC_OPTS
# 2. 숏 캐시: HTML 파일들
aws s3 sync ./out s3://$BUCKET \
--exclude "*" --include "*.html" --exclude "legal/*" \
$SHORT_CACHE $S3_SYNC_OPTS \
--content-type "text/html"
# 3. 숏 캐시: 서비스 워커 파일들 (새로 추가된 핵심 부분)
aws s3 sync ./out s3://$BUCKET \
--exclude "*" --include "sw.js" --include "firebase-messaging-sw.js" \
$SHORT_CACHE $S3_SYNC_OPTS
# 4. 숏 캐시: robots.txt
if [ -f ./out/robots.txt ]; then
aws s3 cp ./out/robots.txt s3://$BUCKET/robots.txt $SHORT_CACHE
fi
- name: Invalidate CloudFront cache (DEV)
if: ${{ github.ref == 'refs/heads/develop' }}
run: |
aws cloudfront create-invalidation \
--distribution-id ${{ secrets.AWS_CLOUDFRONT_DEV_DISTRIBUTION_ID }} \
--paths "/*"