-
Notifications
You must be signed in to change notification settings - Fork 1
55 lines (47 loc) · 1.86 KB
/
deploy.yml
File metadata and controls
55 lines (47 loc) · 1.86 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: Deploy Spring Boot App to EC2 via DockerHub
on:
push:
branches: [main] # main 브랜치에 push가 발생할 때 트리거됨
workflow_dispatch:
jobs:
build-and-deploy:
runs-on: ubuntu-latest # GitHub Actions에서 사용할 runner 환경
steps:
- name: Checkout code
uses: actions/checkout@v3 # 현재 GitHub 레포의 코드 가져오기
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin' # OpenJDK 기반 배포판 사용
- name: Build Spring Boot App
run: ./gradlew clean bootJar # JAR 파일 빌드
- name: Log in to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }} # DockerHub ID
password: ${{ secrets.DOCKERHUB_TOKEN }} # DockerHub Access Token
- name: Build and Push Docker Image
run: |
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/customs-chatbot:latest .
docker push ${{ secrets.DOCKERHUB_USERNAME }}/customs-chatbot:latest
- 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: Deploy to EC2 via SSM
run: |
aws ssm send-command \
--document-name "AWS-RunShellScript" \
--instance-ids "${{ secrets.EC2_INSTANCE_ID }}" \
--region ap-northeast-2 \
--comment "Deploy customs-chatbot" \
--parameters 'commands=[
"cd /home/ubuntu/CustomsChatBotBE",
"git pull origin main",
"chmod +x deploy.sh",
"./deploy.sh"
]' \
--output text