From b9c60711ab1af0ed244a30bc842641aa4fed14ff Mon Sep 17 00:00:00 2001 From: redundant4u Date: Sat, 14 Oct 2023 23:11:48 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20production=20cicd=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy_prod.yml | 78 +++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 .github/workflows/deploy_prod.yml diff --git a/.github/workflows/deploy_prod.yml b/.github/workflows/deploy_prod.yml new file mode 100644 index 000000000..182d37392 --- /dev/null +++ b/.github/workflows/deploy_prod.yml @@ -0,0 +1,78 @@ +name: Deploy Keeper Production Client + +on: + push: + branches: [main] + +jobs: + deploy_production: + runs-on: ubuntu-22.04 + timeout-minutes: 10 + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: "18" + cache: "npm" + + - name: Create Env File + run: | + touch .env + echo "${{ secrets.ENV_PROD }}" >> .env + + - name: Cache node_modules + id: cache + uses: actions/cache@v3 + with: + path: "**/node_modules" + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + + - name: Install Dependencies + if: steps.cache.outputs.cache-hit != 'true' + run: npm ci + + - name: Build + run: CI= npm run build + + - name: Compress + run: tar -zcf ${GITHUB_SHA::8}.tar.gz build + + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v2 + 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 to S3 + run: | + aws s3 mv --region ap-northeast-2 \ + ${GITHUB_SHA::8}.tar.gz \ + ${{ secrets.S3_PROD_FRONT_LOCATION }}/${GITHUB_SHA::8}.tar.gz + + - name: Sync to S3 + run: | + aws s3 sync build ${{ secrets.S3_PROD_FRONT_DEPLOYMENT }} \ + --delete + + - name: Invalidate CloudFront Cache + run: | + aws cloudfront create-invalidation \ + --distribution-id ${{ secrets.CLOUDFRONT_PROD_DISTRIBUTION_ID }} \ + --paths "/*" + + - name: Notify Slack + if: always() + uses: 8398a7/action-slack@v3 + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + with: + status: ${{ job.status }} + author_name: Keeper Production Frontend CICD + fields: repo, commit, message, author, action, took