cupicks / cupicks-fe

이미지만 보고 만드는 카페 레시피 제작 및 공유 서비스
3 stars 1 forks source link

Bug : CI/CD 수행 중 에러 #233

Closed cmun2 closed 2 years ago

cmun2 commented 2 years ago

한 일

Github Actions 수행 중 npm run build에서 에러 발견

에러 내용

image

조치 사항

로컬에서 npm run build 수행시 잘 build가 되지만 Github Actions 내에서는 build과정 중 에러가 난다. image

cmun2 commented 2 years ago

조치사항

경로 에러

cmun2 commented 2 years ago

Invalidation 부분 에러 발생

github action error1

cmun2 commented 2 years ago

Invalidation 무효화 성공

image

# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: release

on:
  pull_request:
    branches:
      - release

jobs:
  build:
    runs-on: ubuntu-18.04

    strategy:
      matrix:
        node-version: [16.13.0]

    steps:
      - name: Checkout source code
        uses: actions/checkout@v3

      - name: node setup
        uses: actions/setup-node@v3
        with:
          node-version: ${{ matrix.node-version }}

      - name: Cachce node_modules
        uses: actions/cache@v2
        id: node-cache
        env:
          cache-name: cache-node-modules
        with:
          path: node_modules
          key: ${{ runner.os }}-node-modules-${{ hashFiles('**/package-lock.json') }}
          restore-keys: |
            ${{ runner.os }}-node-modules-
      - name: Install node_modules
        if: steps.node-cache.outputs.cache-hit != 'true'
        run: npm ci

      - name: Generate Environment Variable Files for Production
        run: |
          pwd
            cd /home/runner/work/cupicks-fe/cupicks-fe
            touch .env
            echo VITE_SERVER_URL=${{secrets.VITE_SERVER_URL}} >> .env
      - name: Build
        run: |
          cd /home/runner/work/cupicks-fe/cupicks-fe
          npm run build

      - name: Deploy
        env:
          AWS_ACCESS_KEY_ID: ${{ secrets.AWS_S3_ACCESS_KEY_ID }}
          AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_S3_SECRET_ACCESS_KEY }}
          AWS_EC2_METADATA_DISABLED: true

        run: |
          aws s3 cp \
          --recursive \
          --region ap-northeast-2 \
          dist s3://cupick.co

      - name: Invalidate CloudFront Cache
        env:
          AWS_ACCESS_KEY_ID: ${{ secrets.AWS_S3_ACCESS_KEY_ID }}
          AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_S3_SECRET_ACCESS_KEY }}
          AWS_EC2_METADATA_DISABLED: true
        run: aws cloudfront create-invalidation --distribution-id ${{secrets.CLOUDFRONT_DISTRIBUTION_ID}} --paths "/*"