-
Notifications
You must be signed in to change notification settings - Fork 3
39 lines (35 loc) · 1.08 KB
/
dotori-master-cd.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
name: Java CICD with Gradle
on:
push:
branches:
- 'master'
jobs:
build:
runs-on: self-hosted
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{secrets.DOCKERHUB_USERNAME}}
password: ${{secrets.DOCKERHUB_TOKEN}}
- name: Deploy to Master
uses: appleboy/ssh-action@master
id: dotori-prod
with:
host: ${{ secrets.HOST_PROD }}
username: ubuntu
password: ${{ secrets.PASSWORD }}
port: 22
key: ${{ secrets.KEYPAIR }}
script: |
sudo docker ps
sudo docker rm -f dotori-prod 2>/dev/null || true
sudo docker pull ${{secrets.DOCKERHUB_USERNAME}}/dotori-prod
sudo docker run --net="host" --name dotori-prod --rm -d -p 8080:8080 ${{secrets.DOCKERHUB_USERNAME}}/dotori-prod
sudo docker image prune -f