This commit is contained in:
xRain 2024-12-25 18:02:11 +08:00
parent 9aee94ee20
commit fdb8159ab6

View File

@ -1,37 +1,36 @@
# action.yml # action.yml
name: 'build docker image and push to code' name: "build docker image and push to code"
description: 'build docker image and push to simcu code' description: "build docker image and push to simcu code"
runs: runs:
using: 'composite' using: "composite"
steps: steps:
- name: build app - name: build app
uses: docker://gradle:jdk21 uses: docker://gradle:jdk21
with: with:
entrypoint: "/bin/bash" entrypoint: "/bin/bash"
args: | args: |
-c "echo 'bootJar {archiveFileName = \"app.jar\"}' >> build.gradle && \ -c "echo 'bootJar {archiveFileName = \"app.jar\"}' >> build.gradle && \
gradle build -x test -Dhttps.proxyHost=100.100.13.14 -Dhttps.proxyPort=8118 \ gradle build -x test -Dhttps.proxyHost=100.100.13.14 -Dhttps.proxyPort=8118 \
-Dhttp.proxyHost=100.100.13.14 -Dhttp.proxyPort=8118 --no-daemon" -Dhttp.proxyHost=100.100.13.14 -Dhttp.proxyPort=8118 --no-daemon"
- name: create dockerfile
uses: docker://ubuntu:latest
with:
entrypoint: "/bin/bash"
args: |
-c 'echo "FROM openjdk:21" > Dockerfile && \
echo "COPY build/libs/app.jar /app.jar" >> Dockerfile && \
echo "ENTRYPOINT [\"java\", \"-jar\", \"/app.jar\"]" >> Dockerfile && \
echo "已经构建完DOCKERFILE了" && \
cat Dockerfile'
- name: create dockerfile - name: build docker image
uses: docker://ubuntu:latest uses: docker://docker:git
with: with:
entrypoint: "/bin/bash" entrypoint: "/bin/sh"
args: | args: |
-c 'echo "FROM openjdk:21" > Dockerfile && \ -c 'docker build -t ${{vars.DOCKER_REGISTRY}}/${{github.repository}}:${{ github.ref_name }} . && \
echo "COPY build/libs/app.jar /app.jar" >> Dockerfile && \ echo ${{vars.DOCKER_REGISTRY}}/${{github.repository}}:${{ github.ref_name }}已经构建完了 && \
echo "ENTRYPOINT [\"java\", \"-jar\", \"/app.jar\"]" >> Dockerfile && \ docker login ${{vars.DOCKER_REGISTRY}} -u ${{vars.DOCKER_USER}} -p ${{vars.DOCKER_PASS}} && \
echo "已经构建完DOCKERFILE了" && \ docker push ${{vars.DOCKER_REGISTRY}}/${{github.repository}}:${{ github.ref_name }} && \
cat Dockerfile' echo ${{vars.DOCKER_REGISTRY}}/${{github.repository}}:${{ github.ref_name }}推送成功'
- name: build docker image
uses: docker://docker:git
with:
entrypoint: "/bin/sh"
args: |
-c 'docker ps && docker info && docker build -t ${{vars.DOCKER_REGISTRY}}/${{github.repository}}:${{ github.ref_name }} . && \
echo ${{vars.DOCKER_REGISTRY}}/${{github.repository}}:${{ github.ref_name }}已经构建完了 && \
docker login ${{vars.DOCKER_REGISTRY}} -u ${{vars.DOCKER_USER}} -p ${{vars.DOCKER_PASS}} && \
docker push ${{vars.DOCKER_REGISTRY}}/${{github.repository}}:${{ github.ref_name }} && \
echo ${{vars.DOCKER_REGISTRY}}/${{github.repository}}:${{ github.ref_name }}推送成功'