-
Notifications
You must be signed in to change notification settings - Fork 0
58 lines (50 loc) · 1.82 KB
/
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
name: CD
on:
push:
branches: [ "master" ]
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set jdk 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Set yml file
uses: microsoft/variable-substitution@v1
with:
files: src/main/resources/application.yml
env:
jwt.access-secret: ${{ secrets.JWT_ACCESS_KEY }}
jwt.refresh-secret: ${{ secrets.JWT_REFRESH_KEY }}
jwt.access-expiry-date: ${{ secrets.JWT_ACCESS_EXPIRY_DATE }}
jwt.refresh-expiry-date: ${{ secrets.JWT_REFRESH_EXPIRY_DATE }}
- name: Build with gradle
run: ./gradlew build
- name: Build docker image
run: |
docker login -u ${{ secrets.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_PASSWORD }}
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/token-server:latest .
docker push ${{ secrets.DOCKERHUB_USERNAME }}/token-server:latest
deploy:
needs: build
runs-on: ubuntu-latest
steps:
- name: Run docker image
uses: appleboy/ssh-action@v0.1.8
with:
host: ${{ secrets.LINUX_HOST }}
username: ${{ secrets.LINUX_USERNAME }}
password: ${{ secrets.LINUX_PASSWORD }}
port: ${{ secrets.LINUX_SSH_PORT }}
script: |
docker login -u ${{ secrets.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_PASSWORD }}
docker stop token-server
docker rm token-server
docker rmi ${{ secrets.DOCKERHUB_USERNAME }}/token-server:latest
docker pull ${{ secrets.DOCKERHUB_USERNAME }}/token-server:latest
docker run -d -p 8050:8050 --name token-server ${{ secrets.DOCKERHUB_USERNAME }}/token-server:latest