-
Notifications
You must be signed in to change notification settings - Fork 1
82 lines (71 loc) ยท 2.8 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
name: Java CI/CD with Gradle
on:
push:
branches: [ "develop" ]
pull_request:
branches: [ ]
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Build with Gradle
run: ./gradlew --warning-mode all build -i
env:
OPEN_AI_KEY: ${{ secrets.OPEN_AI_KEY }}
docker-build:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Grant execute permisson for gradlew
run: chmod +x gradlew
- name: Build with Gradle (without Test)
run: ./gradlew clean build -x test --stacktrace
- name: Docker Hub build & push
run: |
docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} -p ${{ secrets.DOCKER_HUB_PWD }}
docker build --build-arg OPEN_AI_KEY=${{ secrets.OPEN_AI_KEY }} \
--build-arg DEV_DB_HOST=${{ secrets.DEV_DB_HOST }} \
--build-arg DEV_DB_PASSWORD=${{ secrets.DEV_DB_PASSWORD }} \
--build-arg DEV_DB_USER=${{ secrets.DEV_DB_USER }} \
--build-arg PROD_DB_HOST=${{ secrets.PROD_DB_HOST }} \
--build-arg PROD_DB_PASSWORD=${{ secrets.PROD_DB_PASSWORD }} \
--build-arg PROD_DB_USER=${{ secrets.PROD_DB_USER }} \
--build-arg ACTIVE_PROFILE=${{ secrets.ACTIVE_PROFILE }} \
--build-arg S3_BUCKET=${{ secrets.S3_BUCKET }} \
--build-arg REGION=${{ secrets.REGION }} \
--build-arg ACCESS_KEY=${{ secrets.ACCESS_KEY }} \
--build-arg SECRET_KEY=${{ secrets.SECRET_KEY }} \
--build-arg KAKAO_API_KEY=${{ secrets.KAKAO_API_KEY }} \
--build-arg KAKAO_REDIRECT_URI=${{ secrets.KAKAO_REDIRECT_URI }} \
-t ${{ secrets.DOCKER_HUB_USERNAME }}/${{ secrets.DOCKER_HUB_REPO_NAME }} .
docker images
docker push ${{ secrets.DOCKER_HUB_USERNAME }}/${{ secrets.DOCKER_HUB_REPO_NAME }}
- name: deploy
uses: appleboy/ssh-action@master
with:
username: ec2-user
host: ${{ secrets.WAS_HOST }}
key: ${{ secrets.WAS_PRIVATE_KEY }}
port: ${{ secrets.WAS_PORT }}
script: |
sudo docker ps
sudo docker rm -f $(sudo docker ps -qa)
sudo docker pull ${{ secrets.DOCKER_HUB_USERNAME }}/${{ secrets.DOCKER_HUB_REPO_NAME }}
sudo docker run -d -p 8080:8080 ${{ secrets.DOCKER_HUB_USERNAME }}/${{ secrets.DOCKER_HUB_REPO_NAME }}
sudo docker image prune -f