Skip to content

Commit ee5cb3d

Browse files
authored
Create aws.yml
1 parent ac2ae2b commit ee5cb3d

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

.github/workflows/aws.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Didacto-core dev CI/CD Pipeline
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
# 코드 체크아웃
14+
- name: Checkout repository
15+
uses: actions/checkout@v2
16+
17+
# JDK 설치
18+
- name: Set up JDK 17
19+
uses: actions/setup-java@v1
20+
with:
21+
java-version: 17
22+
23+
- name: Set up application.properties
24+
run: echo "${{ secrets.APPLICATION_PROD }}" > ./src/main/resources/application.properties
25+
26+
# Gradle Build
27+
- name: Build with Gradle
28+
run: ./gradlew build
29+
30+
# DockerHub 로그인
31+
- name: Login to DockerHub
32+
uses: docker/login-action@v1
33+
with:
34+
username: ${{ secrets.DOCKER_HUB_USERNAME }}
35+
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
36+
37+
# DockerHub Push
38+
- name: Build and Push Docker image
39+
run: |
40+
docker build -t ${{ secrets.DOCKER_HUB_USERNAME }}/didacto-app-dev .
41+
docker push ${{ secrets.DOCKER_HUB_USERNAME }}/didacto-app-dev
42+
43+
44+
deploy:
45+
runs-on: ubuntu-latest
46+
needs: build
47+
48+
steps:
49+
# AWS 배포
50+
- name: SSH to EC2 and deploy
51+
uses: appleboy/[email protected]
52+
with:
53+
host: ${{ secrets.EC2_HOST }}
54+
username: ${{ secrets.EC2_USER }}
55+
key: ${{ secrets.EC2_SSH_KEY }}
56+
script: |
57+
cd didacto-testserver
58+
sudo docker-compose stop
59+
sudo docker-compose rm -f
60+
sudo docker rmi sjh9708/didacto-app-dev:latest
61+
sudo docker-compose up -d

0 commit comments

Comments
 (0)