-
Notifications
You must be signed in to change notification settings - Fork 1
49 lines (41 loc) · 1.36 KB
/
docker_build_and_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
name: Build and Deploy to Ubuntu Server
on:
push:
branches:
- develop
jobs:
build_and_deploy:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3
- name: Set up JDK 16
uses: actions/setup-java@v3
with:
java-version: '16'
distribution: 'temurin'
- name: Prepare application.properties
run: |
mkdir config
echo "${{ secrets.APP_PROPERTIES }}" > config/application.properties
- name: Build with Maven
run: |
mvn clean
mvn package
- name: web docker build and push
run: |
docker login -u ${{ secrets.DOCKER_REPO }} -p ${{ secrets.DOCKER_KEY }}
docker build -t ${{ secrets.DOCKER_REPO }}/moneyisinvest-backend:latest .
docker push ${{ secrets.DOCKER_REPO }}/moneyisinvest-backend
- name: Deploy to Ubuntu Server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.SSH_PRIVATE_KEY }}
port : 1115
script: |
sudo docker stop backend
sudo docker rm backend
sudo docker pull ${{ secrets.DOCKER_REPO }}/moneyisinvest-backend:latest
sudo docker run -d -p 8080:8080 --net moneyisinvest --name backend ${{ secrets.DOCKER_REPO }}/moneyisinvest-backend:latest