Skip to content

Commit

Permalink
feat: production cicd 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
redundant4u committed Oct 14, 2023
1 parent 12a0dea commit b9c6071
Showing 1 changed file with 78 additions and 0 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/deploy_prod.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit b9c6071

Please sign in to comment.