-
Notifications
You must be signed in to change notification settings - Fork 1
47 lines (39 loc) · 1.07 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
name: Deploy to AWS EC2
on:
push:
branches:
- test
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'temurin'
- name: Set up Docker Environment
run: |
touch ./.env
echo "DB_CONNECTION_URL=${{ secrets.MYSQL_DB_URL }}" >> .env
echo "USER_NAME=${{ secrets.DB_USER }}" >> .env
echo "PASSWORD=${{ secrets.DB_PASSWORD }}" >> .env
echo "FILE_STORAGE_DIR=${{ secrets.FILE_PATH }}" >> .env
shell: bash
# Gradle build
- name: Build with Gradle
run: ./gradlew bootJar
- name: Build and Push Docker image
run: |
docker-compose build
docker-compose up -d
- name: Deploy to EC2
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
docker-compose down
docker-compose up -d