Files
weiyu/.github/workflows/maven.yml
2024-08-20 09:37:10 +08:00

77 lines
2.9 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
#
# github依次添加以下变量
# 路径Settings -> Secrets And Variables -> Actions
# SERVER_HOST / Secret服务器公网IP
# SERVER_USERNAME / Secret服务器用户名
# SERVER_PASSWORD / Secret服务器密码
# SERVER_PORT / Secret服务器端口
name: mycicd
on:
push:
branches: main
# 打标签的时候触发
# tags:
# - '*'
jobs:
build:
runs-on: ubuntu-latest # 运行环境
steps:
- name: checkout code
uses: actions/checkout@v4
# https://github.com/actions/setup-java
- name: install JDK17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: maven
# https://github.com/arduino/setup-protoc
- name: Install Protoc
uses: arduino/setup-protoc@v3
# https://github.com/advanced-security/delombok
# - name: DeLombok
# uses: advanced-security/delombok@v1
# FIXME: Lombok插件无法使用导致log/getters/settings无法使用需要解决。
# 直接本地打包好jar包然后上传到服务器
- name: Maven build
run: |
mvn clean
mvn -B -DskipTests=true install --file pom.xml
cd starter
mvn -B -DskipTests=true package --file pom.xml
# https://github.com/OswaldAKs/CICD-Pipeline-with-GithubActions-Docker
# https://github.com/docker/login-action
# - name: login to docker hub
# uses: docker/login-action@v3
# with:
# username: ${{ secrets.DOCKER_HUB_USERNAME }}
# password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
# https://github.com/docker/build-push-action
# - name: push the docker image to docker hub
# uses: docker/build-push-action@v6
# with:
# context: .
# dockerfile: Dockerfile
# push: true
# tags: ${{ secrets.DOCKER_HUB_USERNAME }}/rest-api:latest
# https://github.com/actions/upload-artifact
# https://github.com/actions/download-artifact
# - name: Upload artifact
# uses: actions/upload-artifact@v4
# with:
# name: my-artifact
# path: path/to/artifact/
# # Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive
# - name: Update dependency graph
# uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6