GiteaActionTest/.gitea/workflows/build-deploy.yaml
hxuanyu fa09874fe0
Some checks failed
Build and Deploy Spring Boot / build-and-deploy (push) Failing after 36s
指定打包时的maven版本
2024-11-04 16:33:38 +08:00

49 lines
1.3 KiB
YAML

name: Build and Deploy Spring Boot
on:
push:
branches: [ master ] # 可以根据需要修改分支名
workflow_dispatch: # 允许手动触发
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
# 检出代码
- uses: actions/checkout@v4
# 设置JDK环境
- name: Set up JDK 8
uses: actions/setup-java@v2
with:
java-version: '8'
distribution: 'adopt'
# 设置maven环境
- name: Set up Maven
uses: stCarolas/setup-maven@v4.5
with:
maven-version: '3.8.6'
# 缓存Maven依赖
- name: Cache Maven packages
uses: actions/cache@v2
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
# 使用Maven打包
- name: Build with Maven
run: mvn clean package -DskipTests
# 使用 scp-action 传输文件
- name: Copy JAR to Server
uses: appleboy/scp-action@master
with:
host: ${{ secrets.SERVER_HOST }}
port: ${{ secrets.SERVER_PORT }}
username: ${{ secrets.SERVER_USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
source: "target/*.jar"
target: "/home/tools/testActions"
strip_components: 1