forked from UMC-CodePlay/CodePlay-BE
-
Notifications
You must be signed in to change notification settings - Fork 0
59 lines (49 loc) · 1.67 KB
/
docker-deploy.yml
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
56
57
58
59
name: Build and Push Docker Image to ECR and Deploy on EC2
on:
pull_request:
branches:
- main
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: ✔️ 리포지토리 가져오기
uses: actions/checkout@v4
- name: ✔️ JDK 17 설치
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: ✔️ Gradle 명령 실행 권한 설정
run: chmod +x gradlew
- 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_DEFAULT_REGION }}
- name: ✔️ Amazon ECR에 로그인
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: ✔️ Docker Image 빌드 및 ECR에 push
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ${{ secrets.ECR_REPOSITORY_NAME }}
IMAGE_TAG: ${{ github.sha }}
run: |
./gradlew jib \
-Djib.to.image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
run-images-on-ec2:
needs: build-and-push
runs-on: ubuntu-latest
steps:
- name: ✔️ EC2 접속 및 배포 스크립트 실행
uses: appleboy/[email protected]
with:
host: ${{ secrets.SSH_HOST_NAME }}
username: ${{ secrets.SSH_USER_NAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: ${{ secrets.SSH_PORT }}
script: |
cd deploy-script
sh ./deploy.sh