-
Notifications
You must be signed in to change notification settings - Fork 0
65 lines (56 loc) · 2.14 KB
/
gradle-publish.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
name: CI/CD using github actions & docker
on:
push:
branches: [ "develop" ] # 해당 branch에 푸쉬 발생 시 업데이트
pull_request:
branches: [ "develop" ]
jobs:
CI-CD:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'temurin'
- name: set yml file
uses: microsoft/variable-substitution@v1
with:
files: src/main/resources/application.yml
env:
spring.datasource.url: ${{ secrets.DB_URL }}
spring.datasource.username: ${{ secrets.DB_USERNAME }}
spring.datasource.password: ${{ secrets.DB_PASSWORD }}
jwt.secret: ${{ secrets.JWT_SECRET }}
spring.ai.openai.api-key: ${{ secrets.OPENAI_API_KEY }}
- name: set ssl yml file
uses: microsoft/variable-substitution@v1
with:
files: src/main/resources/application-ssl.yml
env:
server.ssl.key-store-password: ${{ secrets.SSL_PASSWORD }}
- name: Build with Gradle
run: |
echo '${{ secrets.CHEONGFORDO_P12 }}' | base64 --decode > ./src/main/resources/cheongfordo.p12
chmod +x ./gradlew
./gradlew bootJar
- name: Docker build & push to prod
run: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker build -f Dockerfile -t ${{ secrets.DOCKER_USERNAME }}/cheong_for_do:latest .
docker push ${{ secrets.DOCKER_USERNAME }}/cheong_for_do:latest
- name: Deploy to prod
uses: appleboy/ssh-action@master
id: deploy-prod
with:
host: ${{ secrets.HOST_PROD }} # EC2 퍼블릭 IPv4 DNS
username: ubuntu
key: ${{ secrets.PRIVATE_KEY }} # EC2 private key
envs: GITHUB_SHA
script: |
docker stop cheong_for_do
docker rm cheong_for_do
docker rmi ${{ secrets.DOCKER_USERNAME }}/cheong_for_do:latest
docker pull ${{ secrets.DOCKER_USERNAME }}/cheong_for_do:latest
docker run -d -p 443:8080 --name cheong_for_do ${{ secrets.DOCKER_USERNAME }}/cheong_for_do:latest