Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add AWS CI with Codedeploy #55

Merged
merged 1 commit into from
Aug 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Deploy to Amazon EC2
on:
push:
branches:
- develop
env:
S3_BUCKET_NAME: moaroom-frontend-codedeploy
CODE_DEPLOY_APPLICATION_NAME: moaroom-frontend
CODE_DEPLOY_DEPLOYMENT_GROUP_NAME: moaroom-frontend-dg
permissions:
contents: read

jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
enviornment: production

steps:
- name: Checkout source code. # Repo checkout
uses: actions/checkout@v2
- name: Check Node v # Node v 확인
run: node -v
- name: Install Dependencies # 의존 파일 설치
run: npm install
- name: Build # React Build
run: npm run build
- name: zip create
run: zip -qq -r ./build-fe.zip .
shell: bash
- 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: ${{ secrets.AWS_REGION }}

- name: Upload to AWS S3
run: |
aws s3 cp --region ${{ secrets.AWS_REGION }} ./build-fe.zip s3://$S3_BUCKET_NAME/build-fe.zip
- name: Deploy to AWS EC2 from S3
run: aws deploy create-deployment \
--application-name ${{ env.CODE_DEPLOY_APPLICATION_NAME }} \
--deployment-config-name CodeDeployDefault.AllAtOnce \
--deployment-group-name ${{ env.CODE_DEPLOY_DEPLOYMENT_GROUP_NAME }} \
--s3-location bucket=$S3_BUCKET_NAME,key=build-fe.zip,bundleType=zip
20 changes: 20 additions & 0 deletions appspec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: 0.0
os: linux

files:
- source: /
destination: /home/ubuntu/MoaRoom-Front
overwrite: yes

permissions:
- object: /
pattern: "**"
owner: ubuntu
group: ubuntu
mode: 755

hooks:
ApplicationStart:
- location: scripts/deploy.sh
timeout: 60
runas: ubuntu
5 changes: 5 additions & 0 deletions scripts/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

PROJECT_ROOT="/home/ubuntu/MoaRoom-Front"
echo "> FE 배포"
sudo cp -rf /home/ubuntu/deploy-fe/dist/* /var/www/html
Loading