From be6c5ff6e79a3303590975204a6544935c29ba03 Mon Sep 17 00:00:00 2001 From: smf Date: Sat, 2 Mar 2024 19:48:13 +0800 Subject: [PATCH] build_java --- .github/workflows/build_java.yml | 52 ++++++++++++++++++++++++++++ .github/workflows/publish_docker.yml | 10 ++++-- 2 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/build_java.yml diff --git a/.github/workflows/build_java.yml b/.github/workflows/build_java.yml new file mode 100644 index 0000000..3ad5fe0 --- /dev/null +++ b/.github/workflows/build_java.yml @@ -0,0 +1,52 @@ +on: + workflow_call: + inputs: + maven-version: + required: true + type: string + java-version: + required: true + type: string + artifact-name: + required: true + type: string + +jobs: + build_java_project: + runs-on: ubuntu_act_on_20 + # container: + # image: catthehacker/ubuntu:act-latest + env: + RUNNER_TOOL_CACHE: /toolcache + steps: + - uses: actions/checkout@v3 + + - name: Set up Maven + uses: stCarolas/setup-maven@v5 + with: + maven-version: ${{ inputs.maven-version }} + + - uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '${{ inputs.java-version }}' + # cache: 'maven' + + - name: Cache local Maven repository + uses: actions/cache@v4 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven- + # key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + # restore-keys: | + # ${{ runner.os }}-maven- + + - name: Build with Maven + run: mvn --batch-mode package --file pom.xml -Dhttps.proxyHost=act_clash -Dhttps.proxyPort=7890 -Dhttp.proxyHost=act_clash -Dhttp.proxyPort=7890 + + - uses: actions/upload-artifact@v3 + with: + name: ${{ inputs.artifact-name }} + path: | + target + docker \ No newline at end of file diff --git a/.github/workflows/publish_docker.yml b/.github/workflows/publish_docker.yml index 7351753..fffa135 100644 --- a/.github/workflows/publish_docker.yml +++ b/.github/workflows/publish_docker.yml @@ -6,6 +6,12 @@ on: artifact-name: required: true type: string + docker_context: + required: true + type: string + dockerfile_path: + required: true + type: string jobs: @@ -59,8 +65,8 @@ jobs: http_proxy=http://192.168.0.20:7890 https_proxy=http://192.168.0.20:7890 version=${{ steps.meta.outputs.REPO_VERSION }} - context: . - file: ./docker/Dockerfile + context: ${{ inputs.docker_context }} + file: ${{ inputs.dockerfile_path }} platforms: | linux/amd64 linux/arm64