-
Notifications
You must be signed in to change notification settings - Fork 0
55 lines (47 loc) · 1.56 KB
/
cd.yml
File metadata and controls
55 lines (47 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
name: CD for main
on:
push:
branches: [main]
workflow_dispatch:
inputs:
branch:
description: 'Branch to deploy from'
required: true
default: 'develop'
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- 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: Login to Amazon ECR
uses: aws-actions/amazon-ecr-login@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build and push Docker image (single arch)
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64 # ⚡ 멀티 플랫폼 제거 → 빌드 속도 2~3배 향상
push: true
tags: 867344478016.dkr.ecr.ap-northeast-2.amazonaws.com/enjoy-app:latest
cache-from: type=gha
cache-to: type=gha,mode=max
- name: SSH into EC2 and deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ec2-user
key: ${{ secrets.SSH_PRIVATE_KEY }}
timeout: 300s
script: |
cd /home/ec2-user/back
docker-compose down
docker pull 867344478016.dkr.ecr.ap-northeast-2.amazonaws.com/enjoy-app:latest
docker-compose up -d