From 03842ed979c3cc790c5680a97a8bba749aa41096 Mon Sep 17 00:00:00 2001 From: changui <122252160+changuii@users.noreply.github.com> Date: Wed, 10 Dec 2025 19:59:39 +0900 Subject: [PATCH] =?UTF-8?q?[FIX]=20cloudfront=20=EC=BA=90=EC=8B=9C=20?= =?UTF-8?q?=EB=AC=B4=ED=9A=A8=ED=99=94=20=EA=B2=BD=EB=A1=9C=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD=20(#9)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: cloudfront 입장에서 캐시 무효화 경로 추가 * fix: prod의 무효화 경로도 전체 캐시가 아닌 "/"만 하도록 변경 --- .github/workflows/dev-cicd.yml | 2 +- .github/workflows/prod-cicd.yml | 47 +++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/prod-cicd.yml diff --git a/.github/workflows/dev-cicd.yml b/.github/workflows/dev-cicd.yml index ac5c656..66cc617 100644 --- a/.github/workflows/dev-cicd.yml +++ b/.github/workflows/dev-cicd.yml @@ -50,4 +50,4 @@ jobs: run: | aws cloudfront create-invalidation \ --distribution-id ${{ secrets.DEV_CLOUD_FRONT_DISTRIBUTION_ID }} \ - --paths "/web" + --paths "/" diff --git a/.github/workflows/prod-cicd.yml b/.github/workflows/prod-cicd.yml new file mode 100644 index 0000000..9c20e6c --- /dev/null +++ b/.github/workflows/prod-cicd.yml @@ -0,0 +1,47 @@ +name: Frontend CI/CD PROD + +on: + push: + branches: [prod] + workflow_dispatch: + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + + steps: + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 'lts/*' + + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Create .env.production + run: | + echo "VITE_API_HOST=${{ secrets.PROD_API_HOST }}" > .env.production + + - name: Install dependencies + run: npm ci + + - name: Build with Vite + run: npm run build + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 + 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 build files to S3 + run: | + aws s3 sync ./dist s3://${{ secrets.PROD_S3_BUCKET_NAME }}/web \ + --delete + + - name: Invalidate CloudFront cache + run: | + aws cloudfront create-invalidation \ + --distribution-id ${{ secrets.PROD_CLOUD_FRONT_DISTRIBUTION_ID }} \ + --paths "/" \ No newline at end of file