Skip to content

Commit 6f3d69d

Browse files
committed
feat: 添加 Github Action 配置
1 parent 91c415d commit 6f3d69d

File tree

1 file changed

+54
-36
lines changed

1 file changed

+54
-36
lines changed

.github/workflows/maven.yml

Lines changed: 54 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,61 @@
1-
name: Java CI
1+
name: Java CI with Maven
22

3-
on: [push]
3+
on:
4+
push:
5+
branches:
6+
- server-demo
47

58
jobs:
6-
test_eight:
7-
8-
runs-on: ubuntu-latest
9-
10-
steps:
11-
- uses: actions/checkout@v1
12-
- name: Set up JDK 1.8
13-
uses: actions/setup-java@v1
14-
with:
15-
java-version: 1.8
16-
- name: Build with Maven
17-
run: mvn test
18-
19-
test_nine:
20-
9+
build:
10+
name: 编译
2111
runs-on: ubuntu-latest
22-
12+
strategy:
13+
matrix:
14+
java-version: [8,9,11]
2315
steps:
24-
- uses: actions/checkout@v1
25-
- name: Set up JDK 9
26-
uses: actions/setup-java@v1
27-
with:
28-
java-version: 9
29-
- name: Build with Maven
30-
run: mvn test
31-
32-
test_eleven:
33-
16+
- uses: actions/checkout@v2
17+
- name: Set up JDK ${{ matrix.java-version }}
18+
uses: actions/setup-java@v1
19+
with:
20+
java-version: ${{ matrix.java-version }}
21+
- name: Build with Maven
22+
run: mvn -B package --file pom.xml
23+
deploy:
24+
name: 部署
3425
runs-on: ubuntu-latest
35-
3626
steps:
37-
- uses: actions/checkout@v1
38-
- name: Set up JDK 11
39-
uses: actions/setup-java@v1
40-
with:
41-
java-version: 11
42-
- name: Build with Maven
43-
run: mvn test
27+
- name: 拉取代码
28+
uses: actions/checkout@v2
29+
- name: 安装 JDK 11
30+
uses: actions/setup-java@v1
31+
with:
32+
java-version: 11
33+
- name: 编译
34+
run: mvn -B package --file pom.xml
35+
- name: 删除旧版本 jar 包
36+
uses: appleboy/ssh-action@master
37+
with:
38+
host: ${{ secrets.HOST }}
39+
username: ${{ secrets.USER }}
40+
key: ${{ secrets.SERVER_SSH_KEY }}
41+
script: |
42+
cd /root/docker/project/lin_cms_springboot_demo/app
43+
rm -rf latticy-*.jar
44+
- name: 上传 jar 包
45+
uses: easingthemes/[email protected]
46+
env:
47+
ARGS: "-rltgoDzvO"
48+
SOURCE: "target/latticy-*.jar"
49+
REMOTE_HOST: ${{ secrets.HOST }}
50+
REMOTE_USER: ${{ secrets.USER }}
51+
SSH_PRIVATE_KEY: ${{ secrets.SERVER_SSH_KEY }}
52+
TARGET: ${{ secrets.REMOTE_TARGET }}
53+
- name: 启动程序
54+
uses: appleboy/ssh-action@master
55+
with:
56+
host: ${{ secrets.HOST }}
57+
username: ${{ secrets.USER }}
58+
key: ${{ secrets.SERVER_SSH_KEY }}
59+
script: |
60+
cd /root/docker/project/lin_cms_springboot_demo
61+
docker-compose up -d

0 commit comments

Comments
 (0)