-
Notifications
You must be signed in to change notification settings - Fork 0
67 lines (54 loc) · 2.02 KB
/
gradle.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
60
61
62
63
64
65
66
67
name: Deploy Development Server
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
# branch 현재 비어있는 ubuntu에 내려받기
- name: checkout
uses: actions/checkout@v3
# java 다운받기
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Build with Gradle
run: |
chmod +x ./gradlew
./gradlew bootJar
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Docker Image Build and Push
run: |
docker build -t ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_SERVER }} .
docker push ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_SERVER }}
docker build -f dockerfile-nginx -t ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_NGINX }} .
docker push ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_NGINX }}
- name: Deploy to EC2
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ubuntu
key: ${{ secrets.KEY }}
script: |
cd /home/ubuntu/
sudo touch .env
echo "${{ secrets.ENV_VARS }}" | sudo tee .env > /dev/null
sudo touch docker-compose.yml
echo "${{ secrets.DOCKER_COMPOSE }}" | sudo tee docker-compose.yml > /dev/null
sudo chmod 666 /var/run/docker.sock
sudo docker rm -f $(sudo docker ps -qa)
sudo docker pull ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_SERVER }}
sudo docker pull ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_NGINX }}
docker-compose -f docker-compose.yml --env-file ./.env up -d
docker image prune -f