-
Notifications
You must be signed in to change notification settings - Fork 0
60 lines (51 loc) · 1.98 KB
/
deploy.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
name: Dev
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'
- name: Gradle Caching
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with gradle
run : ./gradlew build -x test -x asciidoctor
- name: Build Docker image
run: |
docker login -u ${{ secrets.DOCKERHUB_ID }} -p ${{ secrets.DOCKERHUB_PASSWORD }}
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/mju-graduate-server:v2 \
--build-arg DATASOURCE_URL=${{ secrets.DATASOURCE_URL }} \
--build-arg DATASOURCE_USERNAME=${{ secrets.DATASOURCE_USERNAME }} \
--build-arg DATASOURCE_PASSWORD=${{ secrets.DATASOURCE_PASSWORD }} \
--build-arg JWT_SECRET=${{ secrets.JWT_SECRET }} .
docker push ${{ secrets.DOCKERHUB_USERNAME }}/mju-graduate-server:v2
- name: Docker Deploy executing remote ssh commands using ssh_key
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.WAS_HOST }}
username: ${{ secrets.WAS_USERNAME }}
key: ${{ secrets.WAS_KEY }}
script : |
cd ~/mju-graduate-server
docker stop $(docker ps -a -q)
docker pull ${{ secrets.DOCKERHUB_USERNAME }}/mju-graduate-server:v2
docker rm -f $(docker ps -a -q)
docker run -d --name mju-graduate-server -p 8080:8080 ${{ secrets.DOCKERHUB_USERNAME }}/mju-graduate-server:v2
docker image prune -f