Skip to content

Commit

Permalink
refactor: cd process 최적화
Browse files Browse the repository at this point in the history
  • Loading branch information
masiljangajji committed Dec 3, 2024
1 parent 4e4b568 commit 7260185
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Continuous Deployment

on:
push:
branches: [ main,docker-test ]
branches: [ main ]

env:
PROJECT_NAME: front
Expand All @@ -11,14 +11,23 @@ env:

jobs:
build-and-push-to-docker-and-deploy:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:

- name: Checkout Base Code
- name: Checkout PR
uses: actions/checkout@v3
with:
ref: ${{ github.event.push.base_ref }}

- name: Cache npm dependencies
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-

- name: Install Dependencies
run: npm ci

Expand All @@ -44,11 +53,9 @@ jobs:
tags: |
masiljangajji/front-app:latest
masiljangajji/front-app:${{ github.sha }}
cache-from: type=inline
cache-to: type=inline

- name: Zip artifact for CodeDeploy
run: |
zip -r $GITHUB_SHA.zip appspec.yml scripts/

- name: AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
Expand All @@ -57,11 +64,13 @@ jobs:
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-northeast-2

- name: S3 Upload zip
run: aws s3 cp --region ap-northeast-2 ./$GITHUB_SHA.zip s3://${{ secrets.BUCKET_NAME }}/${{ env.PROJECT_NAME }}/$GITHUB_SHA.zip

- name: CodeDeploy
run: aws deploy create-deployment --application-name $CODE_DEPLOY_APP_NAME --deployment-config-name CodeDeployDefault.OneAtATime --deployment-group-name $DEPLOYMENT_GROUP_NAME --s3-location bucket=${{ secrets.BUCKET_NAME }},bundleType=zip,key=${{ env.PROJECT_NAME }}/$GITHUB_SHA.zip
- name: Deploy via CodeDeploy
run: |
aws deploy create-deployment \
--application-name ${{ env.CODE_DEPLOY_APP_NAME }} \
--deployment-config-name CodeDeployDefault.OneAtATime \
--deployment-group-name ${{ env.DEPLOYMENT_GROUP_NAME }} \
--s3-location bucket=${{ secrets.BUCKET_NAME }},bundleType=zip,key=${{ env.PROJECT_NAME }}/deployment.zip
Expand Down

0 comments on commit 7260185

Please sign in to comment.