-
Notifications
You must be signed in to change notification settings - Fork 0
59 lines (49 loc) · 1.63 KB
/
cicd.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: Drinktionary CI/CD
on:
push:
branches: [ main ]
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Clear Gradle cache
run: rm -rf ~/.gradle/caches/
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
env:
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
run: ./gradlew build
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push Docker image
run: |
docker build -t ${{ secrets.DOCKER_USERNAME }}/drinktionary:latest .
docker push ${{ secrets.DOCKER_USERNAME }}/drinktionary:latest
- name: SSH and Deploy
uses: appleboy/[email protected]
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
port: ${{ secrets.PORT }}
script: |
cd /home/ubuntu/sunjoo-server-drinktionary
docker-compose down
docker pull ${{ secrets.DOCKER_USERNAME }}/drinktionary:latest
docker-compose build
docker-compose up -d
docker network connect eureka-network sunjoo-server-drinktionary_drinktionary_1
docker restart sunjoo-server-drinktionary_drinktionary_1