update #140
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |