From 14bca8c52262f2beeac243a7eecb63728089ebb6 Mon Sep 17 00:00:00 2001 From: Kim-Jaemin420 Date: Thu, 14 Mar 2024 00:50:41 +0900 Subject: [PATCH 1/2] =?UTF-8?q?Fix:=20deploy=EC=99=80=20build=20=EB=B6=84?= =?UTF-8?q?=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yml | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 90689077..38637c09 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -7,50 +7,64 @@ on: branches: main jobs: - build-and-deploy: + build: runs-on: ubuntu-latest - steps: - uses: actions/checkout@v3 - - name: Install NVM and get latest LTS version run: | wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" echo "NODE_VERSION=$(nvm version-remote --lts)" >> $GITHUB_ENV - - name: Set up Node.js uses: actions/setup-node@v2 with: node-version: ${{ env.NODE_VERSION }} - - uses: pnpm/action-setup@v3 name: Install pnpm with: version: 8 run_install: true - - name: Build run: pnpm run build env: VITE_BASE_URL: ${{ secrets.VITE_BASE_URL }} VITE_CHAT_URL: ${{ secrets.VITE_CHAT_URL }} + deploy: + runs-on: ubuntu-latest + needs: build + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + steps: + - uses: actions/checkout@v3 + - name: Install NVM and get latest LTS version + run: | + wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash + export NVM_DIR="$HOME/.nvm" + [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" + echo "NODE_VERSION=$(nvm version-remote --lts)" >> $GITHUB_ENV + - name: Set up Node.js + uses: actions/setup-node@v2 + with: + node-version: ${{ env.NODE_VERSION }} + - uses: pnpm/action-setup@v3 + name: Install pnpm + with: + version: 8 + run_install: true - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v1 with: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} aws-region: ap-northeast-2 - - name: Deploy to AWS S3 env: BUCKET_NAME: ${{ secrets.AWS_S3_BUCKET_NAME }} run: | aws s3 rm s3://$BUCKET_NAME/assets/ --recursive aws s3 sync ./dist s3://$BUCKET_NAME - - name: CloudFront Invalidation env: CLOUD_FRONT_ID: ${{ secrets.AWS_CLOUDFRONT_ID }} From 1bfe618ab23e4b36c0e224691f21b231fb4c8023 Mon Sep 17 00:00:00 2001 From: Kim-Jaemin420 Date: Thu, 14 Mar 2024 01:06:44 +0900 Subject: [PATCH 2/2] =?UTF-8?q?Fix:=20deploy,=20build=20=EA=B3=BC=EC=A0=95?= =?UTF-8?q?=EC=9D=84=20=ED=95=A9=EC=B9=98=EA=B3=A0=20if=EB=AC=B8=EC=9C=BC?= =?UTF-8?q?=EB=A1=9C=20=EB=B6=84=EA=B8=B0=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yml | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 38637c09..dd61db2a 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -7,65 +7,53 @@ on: branches: main jobs: - build: + build-and-deploy: runs-on: ubuntu-latest + steps: - uses: actions/checkout@v3 + - name: Install NVM and get latest LTS version run: | wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" echo "NODE_VERSION=$(nvm version-remote --lts)" >> $GITHUB_ENV + - name: Set up Node.js uses: actions/setup-node@v2 with: node-version: ${{ env.NODE_VERSION }} + - uses: pnpm/action-setup@v3 name: Install pnpm with: version: 8 run_install: true + - name: Build run: pnpm run build env: VITE_BASE_URL: ${{ secrets.VITE_BASE_URL }} VITE_CHAT_URL: ${{ secrets.VITE_CHAT_URL }} - deploy: - runs-on: ubuntu-latest - needs: build - if: github.event_name == 'push' && github.ref == 'refs/heads/main' - steps: - - uses: actions/checkout@v3 - - name: Install NVM and get latest LTS version - run: | - wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash - export NVM_DIR="$HOME/.nvm" - [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" - echo "NODE_VERSION=$(nvm version-remote --lts)" >> $GITHUB_ENV - - name: Set up Node.js - uses: actions/setup-node@v2 - with: - node-version: ${{ env.NODE_VERSION }} - - uses: pnpm/action-setup@v3 - name: Install pnpm - with: - version: 8 - run_install: true - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v1 with: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} aws-region: ap-northeast-2 + - name: Deploy to AWS S3 + if: github.ref == 'refs/heads/main' env: BUCKET_NAME: ${{ secrets.AWS_S3_BUCKET_NAME }} run: | aws s3 rm s3://$BUCKET_NAME/assets/ --recursive aws s3 sync ./dist s3://$BUCKET_NAME + - name: CloudFront Invalidation + if: github.ref == 'refs/heads/main' env: CLOUD_FRONT_ID: ${{ secrets.AWS_CLOUDFRONT_ID }} run: aws cloudfront create-invalidation --distribution-id $CLOUD_FRONT_ID --paths /*